Author: markt
Date: Tue Nov 13 14:32:18 2012
New Revision: 1408752
URL: http://svn.apache.org/viewvc?rev=1408752&view=rev
Log:
Make parameter names in MediaType case-insensitive.
Based on review by kkolinko
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/HttpParser.java
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/MediaType.java
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1408750
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/HttpParser.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/HttpParser.java?rev=1408752&r1=1408751&r2=1408752&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/HttpParser.java
(original)
+++
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/HttpParser.java
Tue Nov 13 14:32:18 2012
@@ -203,9 +203,9 @@ public class HttpParser {
if (skipConstant(input, "=") == SkipConstantResult.FOUND) {
String value = readTokenOrQuotedString(input, true);
- parameters.put(attribute, value);
+ parameters.put(attribute.toLowerCase(Locale.US), value);
} else {
- parameters.put(attribute, "");
+ parameters.put(attribute.toLowerCase(Locale.US), "");
}
lookForSemiColon = skipConstant(input, ";");
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/MediaType.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/MediaType.java?rev=1408752&r1=1408751&r2=1408752&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/MediaType.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/parser/MediaType.java
Tue Nov 13 14:32:18 2012
@@ -17,6 +17,7 @@
package org.apache.tomcat.util.http.parser;
import java.util.LinkedHashMap;
+import java.util.Locale;
import java.util.Map;
public class MediaType {
@@ -59,7 +60,7 @@ public class MediaType {
}
public String getParameterValue(String parameter) {
- return parameters.get(parameter);
+ return parameters.get(parameter.toLowerCase(Locale.US));
}
@Override
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java?rev=1408752&r1=1408751&r2=1408752&view=diff
==============================================================================
---
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/parser/TestMediaType.java
Tue Nov 13 14:32:18 2012
@@ -19,6 +19,8 @@ package org.apache.tomcat.util.http.pars
import java.io.IOException;
import java.io.StringReader;
+import junit.framework.Assert;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -257,4 +259,15 @@ public class TestMediaType {
return sb.toString();
}
}
+
+ @Test
+ public void testCase() throws Exception {
+ StringReader sr = new StringReader("type/sub-type;a=1;B=2");
+ MediaType m = HttpParser.parseMediaType(sr);
+
+ Assert.assertEquals("1", m.getParameterValue("A"));
+ Assert.assertEquals("1", m.getParameterValue("a"));
+ Assert.assertEquals("2", m.getParameterValue("B"));
+ Assert.assertEquals("2", m.getParameterValue("b"));
+ }
}
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1408752&r1=1408751&r2=1408752&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Nov 13 14:32:18 2012
@@ -101,8 +101,8 @@
<update>
The HTTP header parser added to address <bug>52811</bug> has been
removed and replaced with the light-weight HTTP header parser created
to
- address <bug>54060</bug>. The new parser includes a work-around has for
- a bug in the Adobe Acrobat Reader 9.x plug-in for Microsoft Internet
+ address <bug>54060</bug>. The new parser includes a work-around for a
+ bug in the Adobe Acrobat Reader 9.x plug-in for Microsoft Internet
Explorer that was identified when the old parser was introduced
(<bug>53814</bug>).
</update>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]