Bug 204682 - do not allow document.domain to be set to the empty string. r=heikki, sr=darin, a=blizzard

This commit is contained in:
mstoltz%netscape.com 2003-05-09 23:56:04 +00:00
Родитель 3367dd7472
Коммит ea695f91ea
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -1945,6 +1945,8 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain)
// Check new domain - must be a superdomain of the current host // Check new domain - must be a superdomain of the current host
// For example, a page from foo.bar.com may set domain to bar.com, // For example, a page from foo.bar.com may set domain to bar.com,
// but not to ar.com, baz.com, or fi.foo.bar.com. // but not to ar.com, baz.com, or fi.foo.bar.com.
if (aDomain.IsEmpty())
return NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN;
nsAutoString current; nsAutoString current;
if (NS_FAILED(GetDomain(current))) if (NS_FAILED(GetDomain(current)))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1956,7 +1958,7 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain)
current.Right(suffix, aDomain.Length()); current.Right(suffix, aDomain.Length());
PRUnichar c = current.CharAt(current.Length() - aDomain.Length() - 1); PRUnichar c = current.CharAt(current.Length() - aDomain.Length() - 1);
if (suffix.Equals(aDomain, nsCaseInsensitiveStringComparator()) && if (suffix.Equals(aDomain, nsCaseInsensitiveStringComparator()) &&
(c == '.' || c == '/')) (c == '.'))
ok = PR_TRUE; ok = PR_TRUE;
} }
if (!ok) { if (!ok) {