From 232f55c8a2e9a3a38438464116696192d0f74605 Mon Sep 17 00:00:00 2001 From: chegar Date: Wed, 23 Oct 2013 14:38:22 +0100 Subject: [PATCH] 8020758: HttpCookie constructor does not throw IAE when name contains a space Reviewed-by: michaelm, msheppar --- src/share/classes/java/net/HttpCookie.java | 2 +- test/java/net/CookieHandler/TestHttpCookie.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/share/classes/java/net/HttpCookie.java b/src/share/classes/java/net/HttpCookie.java index fb02ae3e0..001771226 100644 --- a/src/share/classes/java/net/HttpCookie.java +++ b/src/share/classes/java/net/HttpCookie.java @@ -761,7 +761,7 @@ public final class HttpCookie implements Cloneable { // 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. diff --git a/test/java/net/CookieHandler/TestHttpCookie.java b/test/java/net/CookieHandler/TestHttpCookie.java index 55037a070..2a6526fd9 100644 --- a/test/java/net/CookieHandler/TestHttpCookie.java +++ b/test/java/net/CookieHandler/TestHttpCookie.java @@ -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 @@ public class TestHttpCookie { // 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) { -- GitLab