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.1 diff -u -r1.38.2.1 Cookie.java --- java/org/apache/commons/httpclient/Cookie.java 7 Jul 2003 19:11:00 -0000 1.38.2.1 +++ java/org/apache/commons/httpclient/Cookie.java 17 Oct 2003 07:38:21 -0000 @@ -138,6 +138,7 @@ if (name == null) { throw new IllegalArgumentException("Cookie name may not be null"); } + //TODO: should throw MalformedCookieException if (name.equals("")) { throw new IllegalArgumentException("Cookie name may not be blank"); } Index: java/org/apache/commons/httpclient/cookie/CookieSpecBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java,v retrieving revision 1.16 diff -u -r1.16 CookieSpecBase.java --- java/org/apache/commons/httpclient/cookie/CookieSpecBase.java 12 Jun 2003 19:12:16 -0000 1.16 +++ java/org/apache/commons/httpclient/cookie/CookieSpecBase.java 17 Oct 2003 07:38:22 -0000 @@ -189,13 +189,17 @@ for (int i = 0; i < headerElements.length; i++) { HeaderElement headerelement = headerElements[i]; - Cookie cookie = new Cookie(host, - headerelement.getName(), - headerelement.getValue(), - defaultPath, - null, - false); - + Cookie cookie = null; + try { + cookie = new Cookie(host, + headerelement.getName(), + headerelement.getValue(), + defaultPath, + null, + false); + } catch (IllegalArgumentException e) { + throw new MalformedCookieException(e.getMessage()); + } // cycle through the parameters NameValuePair[] parameters = headerelement.getParameters(); // could be null. In case only a header element and no parameters. Index: test/org/apache/commons/httpclient/TestCookie.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestCookie.java,v retrieving revision 1.22 diff -u -r1.22 TestCookie.java --- test/org/apache/commons/httpclient/TestCookie.java 12 Jun 2003 19:12:16 -0000 1.22 +++ test/org/apache/commons/httpclient/TestCookie.java 17 Oct 2003 07:38:23 -0000 @@ -786,10 +786,11 @@ public void testInvalidCookieName() { try { - Cookie dummy = new Cookie("localhost", "invalid name", "cooke name may not have blanks"); - fail("IllegalArgumentException must have been thrown"); + CookieSpec parser = new CookieSpecBase(); + parser.parse("localhost", 80, "/", false, "invalid name="); + fail("MalformedCookieException must have been thrown"); } - catch(IllegalArgumentException e) + catch(MalformedCookieException e) { // Expected } @@ -802,10 +803,11 @@ public void testInvalidCookieName2() { try { - Cookie dummy = new Cookie("localhost", "$invalid_name", "cooke name may not start with $"); - fail("IllegalArgumentException must have been thrown"); + CookieSpec parser = new CookieSpecBase(); + parser.parse("localhost", 80, "/", false, "$invalid_name="); + fail("MalformedCookieException must have been thrown"); } - catch(IllegalArgumentException e) + catch(MalformedCookieException e) { // Expected }