Author: markt
Date: Tue Jan 4 18:28:23 2011
New Revision: 1055132
URL: http://svn.apache.org/viewvc?rev=1055132&view=rev
Log:
Partial fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=49000
Consistently handle name only cookies (which are not spec complaint)
Modified:
tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java
tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java?rev=1055132&r1=1055131&r2=1055132&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/http/Cookies.java Tue Jan 4
18:28:23 2011
@@ -283,7 +283,7 @@ public final class Cookies { // extends
// cookie at the end of the cookie header, so if we
// are past the end of the header, but we have a name
// skip to the name-only part.
- if (pos < end && bytes[pos] == '=') {
+ if (pos < (end - 1) && bytes[pos] == '=') {
// Skip whitespace
do {
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=1055132&r1=1055131&r2=1055132&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java (original)
+++ tomcat/trunk/test/org/apache/tomcat/util/http/TestCookies.java Tue Jan 4
18:28:23 2011
@@ -17,31 +17,10 @@
package org.apache.tomcat.util.http;
-import junit.framework.Test;
import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
public class TestCookies extends TestCase {
- public static void main( String args[] ) {
- TestRunner.run(suite());
- }
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new TestSuite(TestCookies.class));
- return suite;
- }
-/*
- int i = 10000000;
- // These tests are not really representative
- while (i-- > 0) {
- test("session=1234567890;name=\"John Q. Public\";");
- }
-// runtests();
- }
- */
-
+
public void testCookies() throws Exception {
test("foo=bar; a=b", "foo", "bar", "a", "b");
test("foo=bar;a=b", "foo", "bar", "a", "b");
@@ -120,6 +99,20 @@ public class TestCookies extends TestCas
test("$Version=0;foo=bar", 0);
}
+
+ public void testNameOnlyCookies() throws Exception {
+ // Bug 49000
+ /*
+ test("fred=1; jim=2; bob", "fred", "1", "jim", "2", "bob", "");
+ test("fred=1; jim=2; bob; george=3", "fred", "1", "jim", "2", "bob",
"",
+ "george", "3");
+ test("fred=1; jim=2; bob=; george=3", "fred", "1", "jim", "2",
+ "bob", "", "george", "3");
+ */
+ test("fred=1; jim=2; bob=", "fred", "1", "jim", "2", "bob", "");
+ }
+
+
public static void test( String s, int val ) throws Exception {
System.out.println("Processing [" + s + "]");
Cookies cs=new Cookies(null);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]