Author: markt
Date: Tue Jul 24 19:04:36 2007
New Revision: 559280

URL: http://svn.apache.org/viewvc?view=rev&rev=559280
Log:
Port cookie value parsing fix from TC6

Modified:
    tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Cookies.java

Modified: 
tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Cookies.java
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Cookies.java?view=diff&rev=559280&r1=559279&r2=559280
==============================================================================
--- tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Cookies.java 
(original)
+++ tomcat/connectors/trunk/util/java/org/apache/tomcat/util/http/Cookies.java 
Tue Jul 24 19:04:36 2007
@@ -250,8 +250,10 @@
             
             cc=bytes[pos];
             if(  cc=='"' ) {
-                startValue++;
-                endValue=indexOf( bytes, startValue, end, cc );
+                endValue=findDelim3( bytes, startValue+1, end, cc );
+                if (endValue == -1) {
+                    endValue = findDelim2(bytes, startValue+1, end);
+                } else startValue++;
                 pos=endValue+1; // to skip to next cookie
              } else {
                 endValue=findDelim2( bytes, startValue, end );
@@ -335,27 +337,26 @@
         return off;
     }
 
-    public static int indexOf( byte bytes[], int off, int end, byte qq )
+    /*
+     *  search for cc but skip \cc as required by rfc2616
+     *  (according to rfc2616 cc should be ")
+     */
+    public static int findDelim3( byte bytes[], int off, int end, byte cc )
     {
         while( off < end ) {
             byte b=bytes[off];
-            if( b==qq )
+            if (b=='\\') {
+                off++;
+                off++;
+                continue;
+            }
+            if( b==cc )
                 return off;
             off++;
         }
-        return off;
+        return -1;
     }
 
-    public static int indexOf( byte bytes[], int off, int end, char qq )
-    {
-        while( off < end ) {
-            byte b=bytes[off];
-            if( b==qq )
-                return off;
-            off++;
-        }
-        return off;
-    }
     
     // XXX will be refactored soon!
     public static boolean equals( String s, byte b[], int start, int end) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to