Index: java/org/apache/commons/httpclient/Cookie.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v retrieving revision 1.38.2.3 diff -u -r1.38.2.3 Cookie.java --- java/org/apache/commons/httpclient/Cookie.java 22 Feb 2004 18:21:13 -0000 1.38.2.3 +++ java/org/apache/commons/httpclient/Cookie.java 3 Jun 2004 19:28:12 -0000 @@ -1,5 +1,5 @@ /* - * $Header: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v 1.38.2.3 2004/02/22 18:21:13 olegk Exp $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v 1.38.2.3 2004/02/22 18:21:13 olegk Exp $ * $Revision: 1.38.2.3 $ * $Date: 2004/02/22 18:21:13 $ * @@ -112,14 +112,8 @@ if (name == null) { throw new IllegalArgumentException("Cookie name may not be null"); } - if (name.equals("")) { + if (name.trim().equals("")) { throw new IllegalArgumentException("Cookie name may not be blank"); - } - if (name.indexOf(' ') != -1) { - throw new IllegalArgumentException("Cookie name may not contain blanks"); - } - if (name.startsWith("$")) { - throw new IllegalArgumentException("Cookie name may not start with $"); } this.setPath(path); this.setDomain(domain); Index: java/org/apache/commons/httpclient/cookie/RFC2109Spec.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java,v retrieving revision 1.14.2.2 diff -u -r1.14.2.2 RFC2109Spec.java --- java/org/apache/commons/httpclient/cookie/RFC2109Spec.java 22 Feb 2004 18:21:15 -0000 1.14.2.2 +++ java/org/apache/commons/httpclient/cookie/RFC2109Spec.java 3 Jun 2004 19:28:14 -0000 @@ -1,5 +1,5 @@ /* - * $Header: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java,v 1.14.2.2 2004/02/22 18:21:15 olegk Exp $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/RFC2109Spec.java,v 1.14.2.2 2004/02/22 18:21:15 olegk Exp $ * $Revision: 1.14.2.2 $ * $Date: 2004/02/22 18:21:15 $ * @@ -131,6 +131,14 @@ // Perform generic validation super.validate(host, port, path, secure, cookie); // Perform RFC 2109 specific validation + + if (cookie.getName().indexOf(' ') != -1) { + throw new MalformedCookieException("Cookie name may not contain blanks"); + } + if (cookie.getName().startsWith("$")) { + throw new MalformedCookieException("Cookie name may not start with $"); + } + if (cookie.isDomainAttributeSpecified() && (!cookie.getDomain().equals(host))) { Index: test/org/apache/commons/httpclient/TestCookie.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestCookie.java,v retrieving revision 1.22.2.3 diff -u -r1.22.2.3 TestCookie.java --- test/org/apache/commons/httpclient/TestCookie.java 22 Feb 2004 18:21:16 -0000 1.22.2.3 +++ test/org/apache/commons/httpclient/TestCookie.java 3 Jun 2004 19:28:17 -0000 @@ -1,5 +1,5 @@ /* - * $Header: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/Attic/TestCookie.java,v 1.22.2.3 2004/02/22 18:21:16 olegk Exp $ + * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java,v 1.22.2.3 2004/02/22 18:21:16 olegk Exp $ * $Revision: 1.22.2.3 $ * $Date: 2004/02/22 18:21:16 $ * ==================================================================== @@ -754,8 +754,7 @@ public void testInvalidCookieName() { try { - CookieSpec parser = new CookieSpecBase(); - parser.parse("localhost", 80, "/", false, "invalid name="); + cookieParse("localhost", "/", false, new Header("Set-Cookie", "invalid name=")); fail("MalformedCookieException must have been thrown"); } catch(MalformedCookieException e) @@ -771,8 +770,7 @@ public void testInvalidCookieName2() { try { - CookieSpec parser = new CookieSpecBase(); - parser.parse("localhost", 80, "/", false, "$invalid_name="); + cookieParse("localhost", "/", false, new Header("Set-Cookie", "$invalid_name=")); fail("MalformedCookieException must have been thrown"); } catch(MalformedCookieException e)