Summary: | NullPointerException caused by invalid contentType, e.g. trailing semicolon | ||
---|---|---|---|
Product: | Tomcat 7 | Reporter: | Christian <cdanzmann> |
Component: | Catalina | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 7.0.42 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All |
Description
Christian
2013-08-20 09:30:09 UTC
I'm unable to reproduce this with a unit test on Tomcat 7.0.x or 8.0.x nor with a JSP with 7.0.x. I have tried with the example provided and with various combinations of whitespace around the ';'. If you are sure this issue affects that latest stable Tomcat 7 release please re-open this issue and attach the simplest possible JSP that demonstrates the issue on a clean Tomcat 7 install of the latest stable release. (In reply to Mark Thomas from comment #1) > I'm unable to reproduce this with a unit test on Tomcat 7.0.x or 8.0.x nor > with a JSP with 7.0.x. I have tried with the example provided and with > various combinations of whitespace around the ';'. > > If you are sure this issue affects that latest stable Tomcat 7 release > please re-open this issue and attach the simplest possible JSP that > demonstrates the issue on a clean Tomcat 7 install of the latest stable > release. Mark I took the <tomcat7.0.x-trunk>/webapps/examples/jsp/jsp2/jspx/basic.jspx and change it like this <jsp:directive.page contentType="text/html;" /> Then I can reproduce the NPE. org.apache.tomcat.util.http.parser.HttpParser.parseMediaType(StringReader) row -> 211 String attribute = readToken(input); the attribute is null and the input is "text/html;;charset=UTF-8" What about if we do a change like this? --- org/apache/tomcat/util/http/parser/HttpParser.java (revision 1515761) +++ org/apache/tomcat/util/http/parser/HttpParser.java (working copy) @@ -210,11 +210,13 @@ while (lookForSemiColon == SkipConstantResult.FOUND) { String attribute = readToken(input); + String value = ""; if (skipConstant(input, "=") == SkipConstantResult.FOUND) { - String value = readTokenOrQuotedString(input, true); + value = readTokenOrQuotedString(input, true); + } + + if (attribute != null) { parameters.put(attribute.toLowerCase(Locale.ENGLISH), value); - } else { - parameters.put(attribute.toLowerCase(Locale.ENGLISH), ""); } lookForSemiColon = skipConstant(input, ";"); Works for me. (In reply to Mark Thomas from comment #4) > Works for me. thanks Fixed in trunk and 7.0.x and will be included in 7.0.43 onwards. |