froehlich    02/05/23 05:01:08

  Modified:    src/java/org/apache/cocoon/components/request/multipart
                        MultipartParser.java FilePartFile.java
                        FilePartArray.java FilePart.java
  Log:
  applied patch from  Jeroen ter Voorde ([EMAIL PROTECTED]).
  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
  1.3       +15 -3     
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MultipartParser.java      19 May 2002 23:13:59 -0000      1.2
  +++ MultipartParser.java      23 May 2002 12:01:08 -0000      1.3
  @@ -72,7 +72,7 @@
    * FilePart: file part
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jeroen ter Voorde</a>
  - * @version CVS $Id: MultipartParser.java,v 1.2 2002/05/19 23:13:59 stefano Exp $
  + * @version CVS $Id: MultipartParser.java,v 1.3 2002/05/23 12:01:08 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();
   
  @@ -322,9 +331,12 @@
               headers.put(tokenizer.nextToken(" :").toLowerCase(),
                       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.3       +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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FilePartFile.java 21 May 2002 12:24:57 -0000      1.2
  +++ FilePartFile.java 23 May 2002 12:01:08 -0000      1.3
  @@ -59,16 +59,13 @@
    * This class represents a file part parsed from a http post stream.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jeroen ter Voorde</a>
  - * @version CVS $Id: FilePartFile.java,v 1.2 2002/05/21 12:24:57 cziegeler Exp $
  + * @version CVS $Id: FilePartFile.java,v 1.3 2002/05/23 12:01:08 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.3       +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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FilePartArray.java        21 May 2002 12:24:57 -0000      1.2
  +++ FilePartArray.java        23 May 2002 12:01:08 -0000      1.3
  @@ -58,16 +58,13 @@
    * This class represents a file part parsed from a http post stream.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jeroen ter Voorde</a>
  - * @version CVS $Id: FilePartArray.java,v 1.2 2002/05/21 12:24:57 cziegeler Exp $
  + * @version CVS $Id: FilePartArray.java,v 1.3 2002/05/23 12:01:08 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.3       +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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FilePart.java     21 May 2002 12:24:57 -0000      1.2
  +++ FilePart.java     23 May 2002 12:01:08 -0000      1.3
  @@ -59,12 +59,16 @@
    * FilePartArray (which is a file in memory)
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jeroen ter Voorde</a>
  - * @version CVS $Id: FilePart.java,v 1.2 2002/05/21 12:24:57 cziegeler Exp $
  + * @version CVS $Id: FilePart.java,v 1.3 2002/05/23 12:01:08 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:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to