Author: markt Date: Tue Sep 2 15:55:59 2014 New Revision: 1622040 URL: http://svn.apache.org/r1622040 Log: Fix the remaining TODO in the new cookie parser
Modified: tomcat/trunk/java/org/apache/tomcat/util/http/parser/Cookie.java tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java Modified: tomcat/trunk/java/org/apache/tomcat/util/http/parser/Cookie.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/parser/Cookie.java?rev=1622040&r1=1622039&r2=1622040&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/http/parser/Cookie.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/http/parser/Cookie.java Tue Sep 2 15:55:59 2014 @@ -362,8 +362,7 @@ public class Cookie { private static void skipInvalidCookie(ByteBuffer bb) { logInvalidHeader(bb); // Invalid cookie value. Skip to the next semi-colon - // TODO Could be a comma - skipUntilSemiColon(bb); + skipUntilSemiColonOrComma(bb); } private static void skipLWS(ByteBuffer bb) { @@ -386,6 +385,16 @@ public class Cookie { } + private static void skipUntilSemiColonOrComma(ByteBuffer bb) { + while(bb.hasRemaining()) { + byte b = bb.get(); + if (b == SEMICOLON_BYTE || b == COMMA_BYTE) { + break; + } + } + } + + private static SkipResult skipByte(ByteBuffer bb, byte target) { if (!bb.hasRemaining()) { Modified: tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java?rev=1622040&r1=1622039&r2=1622040&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java (original) +++ tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java Tue Sep 2 15:55:59 2014 @@ -462,6 +462,14 @@ public class TestCookies { test(true, "$Version=1;{\"a\":true, \"b\":false};a=b", A); } + @Test + public void testSkipSemicolonOrComma() { + // V1 cookies can also use commas to separate cookies + FOO.setVersion(1); + A.setVersion(1); + test(true, "$Version=1;x\tx=yyy,foo=bar;a=b", FOO, A); + } + private void test(boolean useRfc6265, String header, Cookie... expected) { MimeHeaders mimeHeaders = new MimeHeaders(); Cookies cookies = new Cookies(mimeHeaders); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org