From: jfclere Date: Wed, 4 Jul 2007 14:29:19 +0000 (+0000) Subject: Arrange the handling of cookies values. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0ed0f2dd8a0f8de1bc369eb5e9fa2cd893e10b6a;p=tomcat7.0 Arrange the handling of cookies values. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@553218 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/http/Cookies.java b/java/org/apache/tomcat/util/http/Cookies.java index 89e58b0b5..3f0bc0ee9 100644 --- a/java/org/apache/tomcat/util/http/Cookies.java +++ b/java/org/apache/tomcat/util/http/Cookies.java @@ -250,8 +250,10 @@ public final class Cookies { // extends MultiMap { cc=bytes[pos]; if( cc== '\'' || 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,28 +337,27 @@ public final class Cookies { // extends MultiMap { 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 ) { + byte prev = bytes[off]; 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;