You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jo...@apache.org on 2006/08/04 23:24:31 UTC

svn commit: r428889 - in /jakarta/commons/proper/fileupload/trunk: .classpath .project pom.xml src/java/org/apache/commons/fileupload/FileUploadBase.java xdocs/changes.xml

Author: jochen
Date: Fri Aug  4 14:24:30 2006
New Revision: 428889

URL: http://svn.apache.org/viewvc?rev=428889&view=rev
Log:
Eliminated the limitation of a maximum size for a single
header line. (The total size of all headers is already
limited, so there's no need for another limit.)
PR: FILEUPLOAD-108
Submitted-by: Amichai Rothman, amichai2@amichais.net

Modified:
    jakarta/commons/proper/fileupload/trunk/.classpath
    jakarta/commons/proper/fileupload/trunk/.project
    jakarta/commons/proper/fileupload/trunk/pom.xml
    jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java
    jakarta/commons/proper/fileupload/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/fileupload/trunk/.classpath
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/fileupload/trunk/.classpath?rev=428889&r1=428888&r2=428889&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/.classpath (original)
+++ jakarta/commons/proper/fileupload/trunk/.classpath Fri Aug  4 14:24:30 2006
@@ -1,20 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-
 <classpath>
-  <classpathentry excluding="" kind="src" path="src/java">
-  </classpathentry>
-  <classpathentry output="target/test-classes" kind="src" path="src/test">
-  </classpathentry>
-  <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar">
-  </classpathentry>
-  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
-  </classpathentry>
-  <classpathentry kind="var" path="MAVEN_REPO/commons-io/jars/commons-io-1.1.jar">
-  </classpathentry>
-  <classpathentry kind="var" path="MAVEN_REPO/javax.servlet/jars/servlet-api-2.3.jar">
-  </classpathentry>
-  <classpathentry kind="var" path="MAVEN_REPO/javax.portlet/jars/portlet-api-1.0.jar">
-  </classpathentry>
-  <classpathentry kind="output" path="target/classes">
-  </classpathentry>
-</classpath>
\ No newline at end of file
+	<classpathentry path="src/java" kind="src"/>
+	<classpathentry path="src/test" kind="src"/>
+	<classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"/>
+	<classpathentry path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER" kind="con"/>
+	<classpathentry path="target/classes" kind="output"/>
+</classpath>

Modified: jakarta/commons/proper/fileupload/trunk/.project
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/fileupload/trunk/.project?rev=428889&r1=428888&r2=428889&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/.project (original)
+++ jakarta/commons/proper/fileupload/trunk/.project Fri Aug  4 14:24:30 2006
@@ -1,18 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
-
 <projectDescription>
-  <name>commons-fileupload</name>
-  <comment>The FileUpload component provides a simple yet flexible means of adding support for multipart file upload functionality to servlets and web applications.</comment>
-  <projects>
-  </projects>
-  <buildSpec>
-    <buildCommand>
-      <name>org.eclipse.jdt.core.javabuilder</name>
-      <arguments>
-      </arguments>
-    </buildCommand>
-  </buildSpec>
-  <natures>
-    <nature>org.eclipse.jdt.core.javanature</nature>
-  </natures>
+	<name>commons-fileupload</name>
+	<comment>The FileUpload component provides a simple yet flexible means of adding support for multipart file upload functionality to servlets and web applications.</comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
 </projectDescription>

Modified: jakarta/commons/proper/fileupload/trunk/pom.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/fileupload/trunk/pom.xml?rev=428889&r1=428888&r2=428889&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/pom.xml (original)
+++ jakarta/commons/proper/fileupload/trunk/pom.xml Fri Aug  4 14:24:30 2006
@@ -91,6 +91,13 @@
     </developer>
   </developers>
 
+  <contributors>
+    <contributor>
+      <name>Amichai Rothman</name>
+      <email>amichai2@amichais.net</email>
+    </contributor>
+  </contributors>
+
   <licenses>
     <license>
       <name>The Apache Software License, Version 2.0</name>

Modified: jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java?rev=428889&r1=428888&r2=428889&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java (original)
+++ jakarta/commons/proper/fileupload/trunk/src/java/org/apache/commons/fileupload/FileUploadBase.java Fri Aug  4 14:24:30 2006
@@ -154,13 +154,6 @@
     public static final String MULTIPART_MIXED = "multipart/mixed";
 
 
-    /**
-     * The maximum length of a single header line that will be parsed
-     * (1024 bytes).
-     */
-    public static final int MAX_HEADER_SIZE = 1024;
-
-
     // ----------------------------------------------------------- Data members
 
 
@@ -433,46 +426,38 @@
      */
     protected Map /* String, String */ parseHeaders(String headerPart) {
         Map headers = new HashMap();
-        char[] buffer = new char[MAX_HEADER_SIZE];
-        boolean done = false;
-        int j = 0;
-        int i;
-        String header, headerName, headerValue;
-        try {
-            while (!done) {
-                i = 0;
-                // Copy a single line of characters into the buffer,
-                // omitting trailing CRLF.
-                while (i < 2
-                        || buffer[i - 2] != '\r' || buffer[i - 1] != '\n') {
-                    buffer[i++] = headerPart.charAt(j++);
+        int start = 0;
+        int end = 0;
+        for(;;) {
+        	int offset = headerPart.indexOf('\r', end);
+        	if (offset == -1  ||  offset+1 >= headerPart.length()) {
+        		throw new IllegalStateException("Expected headers to be terminated by an empty line.");
+        	}
+        	if (headerPart.charAt(offset+1) != '\n') {
+        		end = offset+1;
+        	} else if (offset == start) {
+        		break;
+        	} else {
+            	String header = headerPart.substring(start, offset);
+            	start = end = offset+2;
+                if (header.indexOf(':') == -1) {
+                    // This header line is malformed, skip it.
+                    continue;
                 }
-                header = new String(buffer, 0, i - 2);
-                if (header.equals("")) {
-                    done = true;
+                String headerName = header.substring(0, header.indexOf(':'))
+                    .trim().toLowerCase();
+                String headerValue =
+                    header.substring(header.indexOf(':') + 1).trim();
+                if (getHeader(headers, headerName) != null) {
+                    // More that one heder of that name exists,
+                    // append to the list.
+                    headers.put(headerName,
+                                getHeader(headers, headerName) + ','
+                                    + headerValue);
                 } else {
-                    if (header.indexOf(':') == -1) {
-                        // This header line is malformed, skip it.
-                        continue;
-                    }
-                    headerName = header.substring(0, header.indexOf(':'))
-                        .trim().toLowerCase();
-                    headerValue =
-                        header.substring(header.indexOf(':') + 1).trim();
-                    if (getHeader(headers, headerName) != null) {
-                        // More that one heder of that name exists,
-                        // append to the list.
-                        headers.put(headerName,
-                                    getHeader(headers, headerName) + ','
-                                        + headerValue);
-                    } else {
-                        headers.put(headerName, headerValue);
-                    }
+                    headers.put(headerName, headerValue);
                 }
-            }
-        } catch (IndexOutOfBoundsException e) {
-            // Headers were malformed. continue with all that was
-            // parsed.
+        	}
         }
         return headers;
     }

Modified: jakarta/commons/proper/fileupload/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/fileupload/trunk/xdocs/changes.xml?rev=428889&r1=428888&r2=428889&view=diff
==============================================================================
--- jakarta/commons/proper/fileupload/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/fileupload/trunk/xdocs/changes.xml Fri Aug  4 14:24:30 2006
@@ -45,13 +45,21 @@
 	  <action dev="jochen" type="update" issue="FILEUPLOAD-109">
 	    Eliminated duplicate code.
 	  </action>
+
 	  <action dev="jochen" type="add" issue="FILEUPLOAD-112">
 	    Added a streaming API.
 	  </action>
+
 	  <action dev="jochen" type="fix" issue="FILEUPLOAD-93">
 	    Eliminated the necessity of a content-length header.
 	  </action>
 
+      <action dev="jochen" type="fix" issue="FILEUPLOAD-108"
+          due-to="Amichai Rothman" due-to-email="amichai2@amichais.net">
+        Eliminated the limitation of a maximum size for a single
+        header line. (The total size of all headers is already
+        limited, so there's no need for another limit.)      
+      </action>
 	</release>
 
     <release version="1.1.1" date="2006-06-08" description="Bugfix release">



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