You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2013/03/12 10:55:50 UTC

svn commit: r1455470 - in /commons/proper/fileupload/trunk: LICENSE.txt RELEASE-NOTES.txt pom.xml src/changes/changes.xml src/main/java/org/apache/commons/fileupload/ParameterParser.java src/test/java/org/apache/commons/fileupload/ParameterParserTest.java

Author: simonetripodi
Date: Tue Mar 12 09:55:49 2013
New Revision: 1455470

URL: http://svn.apache.org/r1455470
Log:
[FILEUPLOAD-199] #comment as suggested by Thomas, shaded the MimeUtility class from javax.mail APIs in order to decode RFC2047 header values #resolve

Modified:
    commons/proper/fileupload/trunk/LICENSE.txt
    commons/proper/fileupload/trunk/RELEASE-NOTES.txt
    commons/proper/fileupload/trunk/pom.xml
    commons/proper/fileupload/trunk/src/changes/changes.xml
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/ParameterParser.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ParameterParserTest.java

Modified: commons/proper/fileupload/trunk/LICENSE.txt
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/LICENSE.txt?rev=1455470&r1=1455469&r2=1455470&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/LICENSE.txt (original)
+++ commons/proper/fileupload/trunk/LICENSE.txt Tue Mar 12 09:55:49 2013
@@ -200,3 +200,53 @@
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
+
+APACHE COMMONS FILEUPLOAD SUBCOMPONENTS:
+
+The Apache Commons FileUpload jar includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+=
+
+For the javax.mail component (http://www.oracle.com/technetwork/java/javamail/index.html)
+This is licensed under the Common Development and Distribution License("CDDL"), see below
+
+Copyright (c) 1997-2011 Oracle and/or its affiliates. All rights reserved.
+ 
+The contents of this file are subject to the terms of either the GNU
+General Public License Version 2 only ("GPL") or the Common Development
+and Distribution License("CDDL") (collectively, the "License").  You
+may not use this file except in compliance with the License.  You can
+obtain a copy of the License at
+https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
+or packager/legal/LICENSE.txt.  See the License for the specific
+language governing permissions and limitations under the License.
+
+When distributing the software, include this License Header Notice in each
+file and include the License file at packager/legal/LICENSE.txt.
+
+GPL Classpath Exception:
+Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the GPL Version 2 section of the License
+file that accompanied this code.
+
+Modifications:
+If applicable, add the following below the License Header, with the fields
+enclosed by brackets [] replaced by your own identifying information:
+"Portions Copyright [year] [name of copyright owner]"
+
+Contributor(s):
+If you wish your version of this file to be governed by only the CDDL or
+only the GPL Version 2, indicate your decision by adding "[Contributor]
+elects to include this software in this distribution under the [CDDL or GPL
+Version 2] license."  If you don't indicate a single choice of license, a
+recipient has the option to distribute your version of this file under
+either the CDDL, the GPL Version 2 or to extend the choice of license to
+its licensees as provided above.  However, if you add GPL Version 2 code
+and therefore, elected the GPL Version 2 license, then the option applies
+only if the new code is made subject to such option by the copyright
+holder.
+
+=
\ No newline at end of file

Modified: commons/proper/fileupload/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/RELEASE-NOTES.txt?rev=1455470&r1=1455469&r2=1455470&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/fileupload/trunk/RELEASE-NOTES.txt Tue Mar 12 09:55:49 2013
@@ -63,6 +63,7 @@ Bug
  * [FILEUPLOAD-189] - DiskFileItemFactory use of FileCleaningTracker is documented or coded wrong
  * [FILEUPLOAD-195] - Error reading the file size larger than 2 gb
  * [FILEUPLOAD-197] - ServletFileUpload isMultipartContent method does not support HTTP PUT
+ * [FILEUPLOAD-199] - Uploads have unexpected results for files with non-ASCII names - support RFC2047
  * [FILEUPLOAD-204] - FileItem.getHeaders() returns always null.
  * [FILEUPLOAD-212] - Insecure request size checking
  * [FILEUPLOAD-214] - ServletFileUpload only accepts POST requests

Modified: commons/proper/fileupload/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/pom.xml?rev=1455470&r1=1455469&r2=1455470&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/pom.xml (original)
+++ commons/proper/fileupload/trunk/pom.xml Tue Mar 12 09:55:49 2013
@@ -210,6 +210,12 @@
       <artifactId>commons-io</artifactId>
       <version>2.2</version>
     </dependency>
+    <dependency>
+      <groupId>javax.mail</groupId>
+      <artifactId>mail</artifactId>
+      <version>1.4.5</version>
+      <optional>true</optional>
+    </dependency>
   </dependencies>
 
   <build>
@@ -231,6 +237,41 @@
           <goals>deploy</goals>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>2.0</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <artifactSet>
+                <includes>
+                  <include>javax.mail:mail</include>
+                </includes>
+              </artifactSet>
+              <filters>
+                <filter>
+                  <artifact>javax.mail:mail</artifact>
+                  <includes>
+                    <include>javax/mail/MessagingException*</include>
+                    <include>javax/mail/internet/MimeUtility*</include>
+                  </includes>
+                </filter>
+              </filters>
+              <relocations>
+                <relocation>
+                  <pattern>javax.mail</pattern>
+                  <shadedPattern>org.apache.commons.fileupload.util.javax.mail</shadedPattern>
+                </relocation>
+              </relocations>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 

Modified: commons/proper/fileupload/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/changes/changes.xml?rev=1455470&r1=1455469&r2=1455470&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/changes/changes.xml (original)
+++ commons/proper/fileupload/trunk/src/changes/changes.xml Tue Mar 12 09:55:49 2013
@@ -97,6 +97,9 @@ The <action> type attribute can be add,u
       <action issue="FILEUPLOAD-197" dev="simonetripodi" type="fix" due-to="David Wolverton">
         ServletFileUpload isMultipartContent method does not support HTTP PUT - thanks Roy T. Fielding and Jochen  Wiedmann
       </action>
+      <action issue="FILEUPLOAD-199" dev="simonetripodi" type="fix" due-to="Mark Thomas">
+        Uploads have unexpected results for files with non-ASCII names - support RFC2047 - thanks Thomas Neidhart
+      </action>
       <action issue="FILEUPLOAD-204" dev="jochen" type="fix" due-to="Hakju Oh">
         FileItem.getHeaders() returns always null.
       </action>

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/ParameterParser.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/ParameterParser.java?rev=1455470&r1=1455469&r2=1455470&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/ParameterParser.java (original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/ParameterParser.java Tue Mar 12 09:55:49 2013
@@ -16,9 +16,12 @@
  */
 package org.apache.commons.fileupload;
 
+import java.io.UnsupportedEncodingException;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.mail.internet.MimeUtility;
+
 /**
  * A simple parser intended to parse sequences of name/value pairs.
  *
@@ -311,6 +314,14 @@ public class ParameterParser {
                 pos++; // skip '='
                 paramValue = parseQuotedToken(new char[] {
                         separator });
+
+                if (paramValue != null) {
+                    try {
+                        paramValue = MimeUtility.decodeText(paramValue);
+                    } catch (UnsupportedEncodingException e) {
+                        // let's keep the original value in this case
+                    }
+                }
             }
             if (hasChar() && (chars[pos] == separator)) {
                 pos++; // skip separator
@@ -319,6 +330,7 @@ public class ParameterParser {
                 if (this.lowerCaseNames) {
                     paramName = paramName.toLowerCase();
                 }
+
                 params.put(paramName, paramValue);
             }
         }

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ParameterParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ParameterParserTest.java?rev=1455470&r1=1455469&r2=1455470&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ParameterParserTest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/ParameterParserTest.java Tue Mar 12 09:55:49 2013
@@ -108,4 +108,15 @@ public class ParameterParserTest {
         assertEquals("BbC04y", params.get("boundary"));
     }
 
+    /**
+     * Test for <a href="http://issues.apache.org/jira/browse/FILEUPLOAD-199">FILEUPLOAD-199</a>
+     */
+    @Test
+    public void fileUpload199() {
+        ParameterParser parser = new ParameterParser();
+        String s = "Content-Disposition: form-data; name=\"file\"; filename=\"=?UTF-8?Q?=D1=82=D0=B5=D1=81=D1=82.txt?=\"\r\n";
+        Map<String, String> params = parser.parse(s, new char[] { ',', ';' });
+        assertEquals("тест.txt", params.get("filename"));
+    }
+
 }