8020758: HttpCookie constructor does not throw IAE when name contains a space
authorchegar
Wed, 23 Oct 2013 14:38:22 +0100
changeset 21346 793a4fec2332
parent 21345 822b73ad4cc0
child 21347 21c6a82adf04
8020758: HttpCookie constructor does not throw IAE when name contains a space Reviewed-by: michaelm, msheppar
jdk/src/share/classes/java/net/HttpCookie.java
jdk/test/java/net/CookieHandler/TestHttpCookie.java
--- a/jdk/src/share/classes/java/net/HttpCookie.java	Wed Oct 23 15:03:49 2013 +0200
+++ b/jdk/src/share/classes/java/net/HttpCookie.java	Wed Oct 23 14:38:22 2013 +0100
@@ -761,7 +761,7 @@
     // from RFC 2068, token special case characters
     //
     // private static final String tspecials = "()<>@,;:\\\"/[]?={} \t";
-    private static final String tspecials = ",;";
+    private static final String tspecials = ",; ";  // deliberately includes space
 
     /*
      * Tests a string and returns true if the string counts as a token.
--- a/jdk/test/java/net/CookieHandler/TestHttpCookie.java	Wed Oct 23 15:03:49 2013 +0200
+++ b/jdk/test/java/net/CookieHandler/TestHttpCookie.java	Wed Oct 23 14:38:22 2013 +0100
@@ -24,7 +24,7 @@
 /**
  * @test
  * @summary Unit test for java.net.HttpCookie
- * @bug 6244040 6277796 6277801 6277808 6294071 6692802 6790677 6901170
+ * @bug 6244040 6277796 6277801 6277808 6294071 6692802 6790677 6901170 8020758
  * @author Edward Wang
  */
 
@@ -381,6 +381,9 @@
         // CR 6692802: HttpOnly flag
         test("set-cookie: CUSTOMER=WILE_E_COYOTE;HttpOnly").httpOnly(true);
         test("set-cookie: CUSTOMER=WILE_E_COYOTE").httpOnly(false);
+
+        // space disallowed in name (both Netscape and RFC2965)
+        test("set-cookie: CUST OMER=WILE_E_COYOTE").nil();
     }
 
     static void header(String prompt) {