Author: markt
Date: Tue Jul 24 19:10:50 2007
New Revision: 559281

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

Modified:
    
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/Cookies.java

Modified: 
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/Cookies.java
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/Cookies.java?view=diff&rev=559281&r1=559280&r2=559281
==============================================================================
--- 
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/Cookies.java
 (original)
+++ 
tomcat/connectors/branches/tc5.0.x/util/java/org/apache/tomcat/util/http/Cookies.java
 Tue Jul 24 19:10:50 2007
@@ -244,8 +244,10 @@
             // quote is valid only in version=1 cookies
             cc=bytes[pos];
             if( ( version == 1 || isSpecial ) && ( 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 );
@@ -321,28 +323,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) {
         int blen = end-start;



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

Reply via email to