提交 88621019 编写于 作者: C chegar

7023713: HttpCookie.domainMatches("hostname.local", "hostname") should return true

Reviewed-by: chegar
Contributed-by: zhouyx@linux.vnet.ibm.com
上级 6bc2b39a
...@@ -748,10 +748,14 @@ public final class HttpCookie implements Cloneable { ...@@ -748,10 +748,14 @@ public final class HttpCookie implements Cloneable {
&& (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length() - 1)) && (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length() - 1))
return false; return false;
// if the host name contains no dot and the domain name is .local // if the host name contains no dot and the domain name
// is .local or host.local
int firstDotInHost = host.indexOf('.'); int firstDotInHost = host.indexOf('.');
if (firstDotInHost == -1 && isLocalDomain) if (firstDotInHost == -1 &&
(isLocalDomain ||
domain.equalsIgnoreCase(host + ".local"))) {
return true; return true;
}
int domainLength = domain.length(); int domainLength = domain.length();
int lengthDiff = host.length() - domainLength; int lengthDiff = host.length() - domainLength;
......
...@@ -362,12 +362,13 @@ public class TestHttpCookie { ...@@ -362,12 +362,13 @@ public class TestHttpCookie {
eq(c1, c2, false); eq(c1, c2, false);
header("Test domainMatches()"); header("Test domainMatches()");
dm(".foo.com", "y.x.foo.com", false); dm(".foo.com", "y.x.foo.com", false);
dm(".foo.com", "x.foo.com", true); dm(".foo.com", "x.foo.com", true);
dm(".com", "whatever.com", false); dm(".com", "whatever.com", false);
dm(".com.", "whatever.com", false); dm(".com.", "whatever.com", false);
dm(".ajax.com", "ajax.com", true); dm(".ajax.com", "ajax.com", true);
dm(".local", "example.local", true); dm(".local", "example.local", true);
dm("example.local", "example", true);
// bug 6277808 // bug 6277808
testCount++; testCount++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册