Author: remm Date: Thu Dec 15 12:15:56 2016 New Revision: 1774426 URL: http://svn.apache.org/viewvc?rev=1774426&view=rev Log: 60482: HTTP/2 shouldn't URL decode the query string.
Added: tomcat/trunk/test/org/apache/coyote/http2/TestStream.java (with props) Modified: tomcat/trunk/java/org/apache/coyote/http2/Stream.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/coyote/http2/Stream.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/Stream.java?rev=1774426&r1=1774425&r2=1774426&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http2/Stream.java (original) +++ tomcat/trunk/java/org/apache/coyote/http2/Stream.java Thu Dec 15 12:15:56 2016 @@ -261,7 +261,7 @@ class Stream extends AbstractStream impl String query = value.substring(queryStart + 1); coyoteRequest.requestURI().setString(uri); coyoteRequest.decodedURI().setString(coyoteRequest.getURLDecoder().convert(uri, false)); - coyoteRequest.queryString().setString(coyoteRequest.getURLDecoder().convert(query, true)); + coyoteRequest.queryString().setString(query); } break; } Added: tomcat/trunk/test/org/apache/coyote/http2/TestStream.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestStream.java?rev=1774426&view=auto ============================================================================== --- tomcat/trunk/test/org/apache/coyote/http2/TestStream.java (added) +++ tomcat/trunk/test/org/apache/coyote/http2/TestStream.java Thu Dec 15 12:15:56 2016 @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ +package org.apache.coyote.http2; + +import java.io.IOException; +import java.nio.ByteBuffer; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Assert; +import org.junit.Test; + +import org.apache.catalina.Context; +import org.apache.catalina.startup.Tomcat; + +public class TestStream extends Http2TestBase { + + @Test + public void testQueryString() throws Exception { + enableHttp2(); + + Tomcat tomcat = getTomcatInstance(); + + // Map the async servlet to /simple so we can re-use the HTTP/2 handling + // logic from the super class. + Context ctxt = tomcat.addContext("", null); + Tomcat.addServlet(ctxt, "simple", new SimpleServlet()); + ctxt.addServletMappingDecoded("/simple", "simple"); + Tomcat.addServlet(ctxt, "query", new QueryStringServlet()); + ctxt.addServletMappingDecoded("/query", "query"); + + tomcat.start(); + + openClientConnection(); + doHttpUpgrade(); + sendClientPreface(); + validateHttp2InitialResponse(); + + byte[] frameHeader = new byte[9]; + ByteBuffer headersPayload = ByteBuffer.allocate(128); + buildGetRequest(frameHeader, headersPayload, null, 3, "/query?foo=b%26a"); + writeFrame(frameHeader, headersPayload); + + readSimpleGetResponse(); + + Assert.assertEquals( + "3-HeadersStart\n" + + "3-Header-[:status]-[200]\n" + + "3-Header-[query]-[foo=b%26a]\n" + + "3-Header-[foo]-[b&a]\n" + + "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + + "3-HeadersEnd\n" + + "3-Body-0\n" + + "3-EndOfStream\n", output.getTrace()); + } + + private static class QueryStringServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + resp.setHeader("query", req.getQueryString()); + resp.setHeader("foo", req.getParameter("foo")); + } + + } + +} Propchange: tomcat/trunk/test/org/apache/coyote/http2/TestStream.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1774426&r1=1774425&r2=1774426&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Thu Dec 15 12:15:56 2016 @@ -92,6 +92,10 @@ <code>ByteBuffer</code> that caused an intermittent failure in the unit tests. (markt) </fix> + <fix> + <bug>60482</bug>: HTTP/2 shouldn't do URL decoding on the query string. + (remm) + </fix> </changelog> </subsection> <subsection name="Web Applications"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org