This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 3937417  Check earlier for valid first character
3937417 is described below

commit 3937417d6beec03f3087af27e0220e1fcc3b29a5
Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org>
AuthorDate: Tue Aug 25 14:28:11 2020 +0300

    Check earlier for valid first character
    
    Move the check for the possible characters in the first position
---
 java/org/apache/catalina/connector/CoyoteAdapter.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/connector/CoyoteAdapter.java 
b/java/org/apache/catalina/connector/CoyoteAdapter.java
index 6249e35..09dcb05 100644
--- a/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -1144,6 +1144,12 @@ public class CoyoteAdapter implements Adapter {
         int pos = 0;
         int index = 0;
 
+
+        // The URL must start with '/' (or '\' that will be replaced soon)
+        if (b[start] != (byte) '/' && b[start] != (byte) '\\') {
+            return false;
+        }
+
         // Replace '\' with '/'
         // Check for null byte
         for (pos = start; pos < end; pos++) {
@@ -1159,11 +1165,6 @@ public class CoyoteAdapter implements Adapter {
             }
         }
 
-        // The URL must start with '/'
-        if (b[start] != (byte) '/') {
-            return false;
-        }
-
         // Replace "//" with "/"
         for (pos = start; pos < (end - 1); pos++) {
             if (b[pos] == (byte) '/') {


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

Reply via email to