HttpCookie.domainMatches("hostname.local", "hostname") return false
Sean Chou
zhouyx at linux.vnet.ibm.com
Wed Mar 16 23:23:49 PDT 2011
Thank Chris.
Here is an alternative fix, with the TestHttpCookie.java updated
together.
diff -r 554adcfb615e src/share/classes/java/net/HttpCookie.java
--- a/src/share/classes/java/net/HttpCookie.java Wed Mar 16 15:01:07 2011
-0700
+++ b/src/share/classes/java/net/HttpCookie.java Thu Mar 17 13:35:24 2011
+0800
@@ -751,6 +751,9 @@
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();
int lengthDiff = host.length() - domainLength;
diff -r 554adcfb615e test/java/net/CookieHandler/TestHttpCookie.java
--- a/test/java/net/CookieHandler/TestHttpCookie.java Wed Mar 16 15:01:07
2011 -0700
+++ b/test/java/net/CookieHandler/TestHttpCookie.java Thu Mar 17 13:35:24
2011 +0800
@@ -368,6 +368,7 @@
dm(".com.", "whatever.com", false);
dm(".ajax.com", "ajax.com", true);
dm(".local", "example.local", true);
+ dm("cocope.local", "cocope", true);
// bug 6277808
testCount++;
2011/3/17 Chris Hegarty <chris.hegarty at oracle.com>
> Hi Sean,
>
> I applied your patch to my local repo and it doesn't compile, startWith ->
> startsWith ;-)
>
> More critically it doesn't resolve the problem, isLocalDomain will be false
> for 'hostname.local'.
>
> I am working on an alternative fix ( please feel free to work on an
> alternative fix also). Additional, we should update
> test/java/net/CookieHandler/TestHttpCookie.java ( under "Test domainMatches"
> ).
>
> -Chris.
>
>
> On 03/14/11 08:03 AM, Sean Chou wrote:
>
>> Hi,
>>
>> Is there any update to this issue? If not, I have a simple patch as
>> follows:
>>
>>
>> diff -r e947a98ea3c1 src/share/classes/java/net/HttpCookie.java
>> --- a/src/share/classes/java/net/HttpCookie.java Thu Mar 10 17:11:08
>> 2011 -0800
>> +++ b/src/share/classes/java/net/HttpCookie.java Mon Mar 14 16:02:14
>> 2011 +0800
>> @@ -771,6 +771,10 @@
>> host.equalsIgnoreCase(domain.substring(1)));
>> }
>>
>> + if (isLocalDomain && domain.startWith(host)){
>> + return true;
>> + }
>> +
>> return false;
>> }
>>
>>
>> 2011/3/2 Chris Hegarty <chris.hegarty at oracle.com
>> <mailto:chris.hegarty at oracle.com>>
>>
>> On 03/ 2/11 01:50 AM, Sean Chou wrote:
>>
>> Hi,
>> If there's no different opinions or objection, can someone
>> raise a
>> bug on the Oracle bug system for me please?
>>
>>
>> Sorry, I though I replied to this.
>>
>> It would appear to be a bug. I filed CR 7023713,
>> "HttpCookie.domainMatches("hostname.local", "hostname") should
>> return true", for this issue.
>>
>> -Chris.
>>
>> Thanks.
>>
>>
>> 2011/2/22 Sean Chou <zhouyx at linux.vnet.ibm.com
>> <mailto:zhouyx at linux.vnet.ibm.com>
>> <mailto:zhouyx at linux.vnet.ibm.com
>> <mailto:zhouyx at 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
>>
>>
>>
>>
>> --
>> Best Regards,
>> Sean Chou
>>
>>
--
Best Regards,
Sean Chou
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/net-dev/attachments/20110317/20b27c19/attachment.html
More information about the net-dev
mailing list