Hi Sean,

I submitted a JPRT job with you patch. If all builds and tests are successful I'll push this change for you.

diff -r 46b53f80ab0a src/share/classes/java/net/HttpCookie.java
--- a/src/share/classes/java/net/HttpCookie.java Fri Aug 19 10:55:05 2011 +0100 +++ b/src/share/classes/java/net/HttpCookie.java Fri Aug 19 15:16:36 2011 +0100
@@ -751,6 +751,11 @@ public final class HttpCookie implements
         // if the host name contains no dot and the domain name is .local
         int firstDotInHost = host.indexOf('.');
         if (firstDotInHost == -1 && isLocalDomain)
+            return true;
+
+ // if the host name contains no dot and the domain name is "host.local"
+        if (firstDotInHost == -1 &&
+            domain.equalsIgnoreCase(host + ".local"))
             return true;

         int domainLength = domain.length();
diff -r 46b53f80ab0a test/java/net/CookieHandler/TestHttpCookie.java
--- a/test/java/net/CookieHandler/TestHttpCookie.java Fri Aug 19 10:55:05 2011 +0100 +++ b/test/java/net/CookieHandler/TestHttpCookie.java Fri Aug 19 15:16:36 2011 +0100
@@ -362,12 +362,13 @@ public class TestHttpCookie {
         eq(c1, c2, false);

         header("Test domainMatches()");
-        dm(".foo.com",  "y.x.foo.com",      false);
-        dm(".foo.com",  "x.foo.com",        true);
-        dm(".com",      "whatever.com",     false);
-        dm(".com.",     "whatever.com",     false);
-        dm(".ajax.com", "ajax.com",         true);
-        dm(".local",    "example.local",    true);
+        dm(".foo.com",      "y.x.foo.com",      false);
+        dm(".foo.com",      "x.foo.com",        true);
+        dm(".com",          "whatever.com",     false);
+        dm(".com.",         "whatever.com",     false);
+        dm(".ajax.com",     "ajax.com",         true);
+        dm(".local",        "example.local",    true);
+        dm("example.local", "example",          true);

         // bug 6277808
         testCount++;

-Chris.


On 04/08/2011 08:09, Sean Chou wrote:
Hi all,

    I checked with java8, this problem still exists; and I checked the
patch, it is still working.
The bug was filed with id 7023713 for java7, and the patch is here. So,
would anyone like to
take a look at it again? Thanks.

2011/2/22 Sean Chou <zho...@linux.vnet.ibm.com
<mailto:zho...@linux.vnet.ibm.com>>

    Hi,
        I find that HttpCookie.domainMatches("hostname.local",
    "hostname") returns false, which may be a bug.
        According to spec, the effective host name of "hostname" is
    "hostname.local", which is string
    exactly the same with the first parameter. Thus the method should
    return true for this invocation.

        I attached the simple testcase here:
    // Testcase
    import java.net.HttpCookie;

    public class DomainMatchTest{

        public static void main(String args[]){
           // "true" should be printed, but get "false".
           System.out.println(HttpCookie.domainMatches("hostname.local",
    "hostname"));
        }

    }
    // End of testcase

    Any comments?

    --
    Best Regards,
    Sean Chou




--
Best Regards,
Sean Chou

Reply via email to