stefano 02/05/19 15:57:00
Modified: src/java/org/apache/cocoon/components/request/multipart Tag:
cocoon_2_0_3_branch MultipartParser.java
Log:
allow the multipart/form-data parser to understand various encodings
based on what is indicated by the request (NOTE: I use a servlet filter
up front that wraps incoming requests to cocoon and sets the
encoding), this allows, for example, to upload an image and a chinese text
together with no problems (yes, I've tested it :-)
Revision Changes Path
No revision
No revision
1.1.2.1 +6 -2
xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/MultipartParser.java
Index: MultipartParser.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/MultipartParser.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- MultipartParser.java 27 Feb 2002 20:21:22 -0000 1.1
+++ MultipartParser.java 19 May 2002 22:57:00 -0000 1.1.2.1
@@ -72,7 +72,7 @@
* FilePart: file part
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jeroen ter Voorde</a>
- * @version CVS $Id: MultipartParser.java,v 1.1 2002/02/27 20:21:22 dims Exp $
+ * @version CVS $Id: MultipartParser.java,v 1.1.2.1 2002/05/19 22:57:00 stefano Exp
$
*/
public class MultipartParser extends Hashtable {
@@ -100,6 +100,8 @@
/** Field maxUploadSize */
private int maxUploadSize;
+ /** Field characterEncoding */
+ private String characterEncoding;
/**
* Constructor, parses given request
*
@@ -125,6 +127,8 @@
this.allowOverwrite = allowOverwrite;
this.silentlyRename = silentlyRename;
this.maxUploadSize = maxUploadSize;
+ this.characterEncoding = request.getCharacterEncoding();
+ if (this.characterEncoding == null) this.characterEncoding = "ISO-8859-1";
if (request.getContentLength() > maxUploadSize) {
throw new IOException("Content length exceeds maximum upload size");
@@ -283,7 +287,7 @@
while (in.getState() == TokenStream.STATE_READING) {
int read = in.read(buf);
- value.append(new String(buf, 0, read));
+ value.append(new String(buf, 0, read, this.characterEncoding));
}
String field = (String) headers.get("name");
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]