commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcna...@apache.org
Subject cvs commit: jakarta-commons-sandbox/fileupload/src/java/org/apache/commons/fileupload DefaultFileItem.java FileUpload.java
Date Thu, 18 Apr 2002 16:10:28 GMT
jmcnally    02/04/18 09:10:28

  Modified:    fileupload/src/java/org/apache/commons/fileupload
                        DefaultFileItem.java FileUpload.java
  Log:
  handling values which may be url encoded.
  
  Revision  Changes    Path
  1.5       +8 -1      jakarta-commons-sandbox/fileupload/src/java/org/apache/commons/fileupload/DefaultFileItem.java
  
  Index: DefaultFileItem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/fileupload/src/java/org/apache/commons/fileupload/DefaultFileItem.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultFileItem.java	11 Apr 2002 06:03:19 -0000	1.4
  +++ DefaultFileItem.java	18 Apr 2002 16:10:28 -0000	1.5
  @@ -54,6 +54,7 @@
    * <http://www.apache.org/>.
    */
   
  +import java.net.URLDecoder;
   import java.io.ByteArrayInputStream;
   import java.io.ByteArrayOutputStream;
   import java.io.BufferedInputStream;
  @@ -91,7 +92,7 @@
    * @author <a href="mailto:sean@informage.net">Sean Legassick</a>
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
  - * @version $Id: DefaultFileItem.java,v 1.4 2002/04/11 06:03:19 jmcnally Exp $
  + * @version $Id: DefaultFileItem.java,v 1.5 2002/04/18 16:10:28 jmcnally Exp $
    */
   public class DefaultFileItem
       implements FileItem
  @@ -249,6 +250,12 @@
                   byteStream = null;
               }
           }
  +        if (isFormField()) 
  +        {
  +            // client may have encoded the parameter
  +            content = URLDecoder.decode(new String(content)).getBytes();
  +        }        
  +
           return content;
       }
   
  
  
  
  1.3       +12 -5     jakarta-commons-sandbox/fileupload/src/java/org/apache/commons/fileupload/FileUpload.java
  
  Index: FileUpload.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/fileupload/src/java/org/apache/commons/fileupload/FileUpload.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileUpload.java	11 Apr 2002 05:57:37 -0000	1.2
  +++ FileUpload.java	18 Apr 2002 16:10:28 -0000	1.3
  @@ -54,6 +54,7 @@
    * <http://www.apache.org/>.
    */
   
  +import java.net.URLDecoder;
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  @@ -87,7 +88,7 @@
    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
  - * @version $Id: FileUpload.java,v 1.2 2002/04/11 05:57:37 jmcnally Exp $
  + * @version $Id: FileUpload.java,v 1.3 2002/04/18 16:10:28 jmcnally Exp $
    */
   public class FileUpload
   {
  @@ -112,6 +113,12 @@
       public static final String ATTACHMENT = "attachment";
   
       /**
  +     * Part of HTTP header.
  +     */
  +    public static final String MULTIPART =
  +        "multipart/";
  +
  +    /**
        * HTTP header.
        */
       public static final String MULTIPART_FORM_DATA =
  @@ -163,10 +170,10 @@
           ArrayList items = new ArrayList();
           String contentType = req.getHeader(CONTENT_TYPE);
   
  -        if(!contentType.startsWith(MULTIPART_FORM_DATA))
  +        if(!contentType.startsWith(MULTIPART))
           {
               throw new FileUploadException("the request doesn't contain a " +
  -                MULTIPART_FORM_DATA + " stream");
  +                MULTIPART_FORM_DATA + " or " + MULTIPART_MIXED + " stream");
           }
           int requestSize = req.getContentLength();
   
  @@ -320,7 +327,7 @@
                   }
               }
           }
  -        return fileName;
  +        return URLDecoder.decode(fileName);
       }
   
       /**
  @@ -342,7 +349,7 @@
                   fieldName = cd.substring(start + 6, end);
               }
           }
  -        return fieldName;
  +        return URLDecoder.decode(fieldName);
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message