Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 72214 invoked by uid 500); 23 May 2002 12:01:47 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 72205 invoked by uid 500); 23 May 2002 12:01:47 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 23 May 2002 12:01:46 -0000 Message-ID: <20020523120146.50025.qmail@icarus.apache.org> From: froehlich@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart MultipartParser.java FilePartFile.java FilePartArray.java FilePart.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N froehlich 02/05/23 05:01:46 Modified: src/java/org/apache/cocoon/components/request/multipart Tag: cocoon_2_0_3_branch MultipartParser.java FilePartFile.java FilePartArray.java FilePart.java Log: applied patch from Jeroen ter Voorde (j.tervoorde@home.nl). getHeaders() in multipart.FilePartFile/Array always returns null! IE6 submits a file part with an empty filename for empty upload controls. This was not correctly handled. Revision Changes Path No revision No revision 1.1.2.2 +16 -4 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.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- MultipartParser.java 19 May 2002 22:57:00 -0000 1.1.2.1 +++ MultipartParser.java 23 May 2002 12:01:46 -0000 1.1.2.2 @@ -72,7 +72,7 @@ * FilePart: file part * * @author Jeroen ter Voorde - * @version CVS $Id: MultipartParser.java,v 1.1.2.1 2002/05/19 22:57:00 stefano Exp $ + * @version CVS $Id: MultipartParser.java,v 1.1.2.2 2002/05/23 12:01:46 froehlich Exp $ */ public class MultipartParser extends Hashtable { @@ -184,7 +184,15 @@ try { if (headers.containsKey("filename")) { - parseFilePart(ts, headers); + if (!"".equals(headers.get("filename"))) { + parseFilePart(ts, headers); + } else { + // IE6 sends an empty part with filename="" for + // empty upload fields. Just parse away the part + byte[] buf = new byte[32]; + while(ts.getState() == TokenStream.STATE_READING) + ts.read(buf); + } } else if (((String) headers.get("content-disposition")) .toLowerCase().equals("form-data")) { parseInlinePart(ts, headers); @@ -226,6 +234,7 @@ out = new ByteArrayOutputStream(); } else { String filePath = uploadDirectory.getPath() + File.separator; + String fileName = new File((String) headers.get("filename")).getName(); @@ -320,11 +329,14 @@ StringTokenizer tokenizer = new StringTokenizer(hdrline); headers.put(tokenizer.nextToken(" :").toLowerCase(), - tokenizer.nextToken(" :;")); + tokenizer.nextToken(" :;")); + // The extra tokenizer.hasMoreTokens() in headers.put + // handles the filename="" case IE6 submits for an empty + // upload field. while (tokenizer.hasMoreTokens()) { headers.put(tokenizer.nextToken(" ;=\""), - tokenizer.nextToken("=\"")); + tokenizer.hasMoreTokens() ? tokenizer.nextToken("=\"") : ""); } hdrline = readln(in); 1.1.2.1 +2 -5 xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartFile.java Index: FilePartFile.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartFile.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- FilePartFile.java 27 Feb 2002 20:21:22 -0000 1.1 +++ FilePartFile.java 23 May 2002 12:01:46 -0000 1.1.2.1 @@ -59,16 +59,13 @@ * This class represents a file part parsed from a http post stream. * * @author Jeroen ter Voorde - * @version CVS $Id: FilePartFile.java,v 1.1 2002/02/27 20:21:22 dims Exp $ + * @version CVS $Id: FilePartFile.java,v 1.1.2.1 2002/05/23 12:01:46 froehlich Exp $ */ public class FilePartFile extends FilePart { /** Field file */ private File file = null; - /** Field headers */ - private Map headers; - /** * Constructor FilePartFile * @@ -76,7 +73,7 @@ * @param file */ protected FilePartFile(Map headers, File file) { - this.headers = headers; + super(headers); this.file = file; } 1.1.2.1 +2 -5 xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartArray.java Index: FilePartArray.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePartArray.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- FilePartArray.java 27 Feb 2002 20:21:22 -0000 1.1 +++ FilePartArray.java 23 May 2002 12:01:46 -0000 1.1.2.1 @@ -58,16 +58,13 @@ * This class represents a file part parsed from a http post stream. * * @author Jeroen ter Voorde - * @version CVS $Id: FilePartArray.java,v 1.1 2002/02/27 20:21:22 dims Exp $ + * @version CVS $Id: FilePartArray.java,v 1.1.2.1 2002/05/23 12:01:46 froehlich Exp $ */ public class FilePartArray extends FilePart { /** Field in */ private InputStream in = null; - /** Field headers */ - private Map headers; - /** * Constructor FilePartArray * @@ -75,7 +72,7 @@ * @param in */ protected FilePartArray(Map headers, InputStream in) { - this.headers = headers; + super(headers); this.in = in; } 1.1.2.1 +7 -3 xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePart.java Index: FilePart.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/FilePart.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- FilePart.java 27 Feb 2002 20:21:22 -0000 1.1 +++ FilePart.java 23 May 2002 12:01:46 -0000 1.1.2.1 @@ -59,12 +59,16 @@ * FilePartArray (which is a file in memory) * * @author Jeroen ter Voorde - * @version CVS $Id: FilePart.java,v 1.1 2002/02/27 20:21:22 dims Exp $ + * @version CVS $Id: FilePart.java,v 1.1.2.1 2002/05/23 12:01:46 froehlich Exp $ */ public abstract class FilePart { - /** Field headers */ - private Map headers; + /** Field headers */ + protected Map headers; + + protected FilePart(Map headers) { + this.headers = headers; + } /** * Returns the part headers ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org