Author: markt
Date: Fri Mar 24 23:58:24 2017
New Revision: 1788569

URL: http://svn.apache.org/viewvc?rev=1788569&view=rev
Log:
:path header must not be empty
Found with the h2spec tool written by Moto Ishizawa.

Modified:
    tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties
    tomcat/trunk/java/org/apache/coyote/http2/Stream.java

Modified: tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties?rev=1788569&r1=1788568&r2=1788569&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/LocalStrings.properties Fri Mar 
24 23:58:24 2017
@@ -76,6 +76,7 @@ stream.closed=Connection [{0}], Stream [
 stream.header.case=Connection [{0}], Stream [{1}], HTTP header name [{2}] must 
be in lower case
 stream.header.debug=Connection [{0}], Stream [{1}], HTTP header [{2}], Value 
[{3}]
 stream.header.duplicate=Connection [{0}], Stream [{1}], received multiple 
[{3}] headers
+stream.header.noPath=Connection [{0}], Stream [{1}], The [:path] pseudo header 
was empty
 stream.header.unexpectedPseudoHeader=Connection [{0}], Stream [{1}], Pseudo 
header [{2}] received after a regular header
 stream.header.unknownPseudoHeader=Connection [{0}], Stream [{1}], Unknown 
pseudo header [{2}] received
 stream.notWritable=Connection [{0}], Stream [{1}], This stream is not writable

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=1788569&r1=1788568&r2=1788569&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/Stream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/Stream.java Fri Mar 24 23:58:24 
2017
@@ -272,24 +272,27 @@ class Stream extends AbstractStream impl
             break;
         }
         case ":path": {
-            if (coyoteRequest.requestURI().isNull()) {
-                int queryStart = value.indexOf('?');
-                if (queryStart == -1) {
-                    coyoteRequest.requestURI().setString(value);
-                    coyoteRequest.decodedURI().setString(
-                            coyoteRequest.getURLDecoder().convert(value, 
false));
-                } else {
-                    String uri = value.substring(0, queryStart);
-                    String query = value.substring(queryStart + 1);
-                    coyoteRequest.requestURI().setString(uri);
-                    coyoteRequest.decodedURI().setString(
-                            coyoteRequest.getURLDecoder().convert(uri, false));
-                    coyoteRequest.queryString().setString(query);
-                }
-            } else {
+            if (!coyoteRequest.requestURI().isNull()) {
                 throw new 
HpackException(sm.getString("stream.header.duplicate",
                         getConnectionId(), getIdentifier(), ":path" ));
             }
+            if (value.length() == 0) {
+                throw new HpackException(sm.getString("stream.header.noPath",
+                        getConnectionId(), getIdentifier()));
+            }
+            int queryStart = value.indexOf('?');
+            if (queryStart == -1) {
+                coyoteRequest.requestURI().setString(value);
+                coyoteRequest.decodedURI().setString(
+                        coyoteRequest.getURLDecoder().convert(value, false));
+            } else {
+                String uri = value.substring(0, queryStart);
+                String query = value.substring(queryStart + 1);
+                coyoteRequest.requestURI().setString(uri);
+                coyoteRequest.decodedURI().setString(
+                        coyoteRequest.getURLDecoder().convert(uri, false));
+                coyoteRequest.queryString().setString(query);
+            }
             break;
         }
         case ":authority": {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to