From ea695f91eab70e134264316d3479a4a0d0969486 Mon Sep 17 00:00:00 2001 From: "mstoltz%netscape.com" Date: Fri, 9 May 2003 23:56:04 +0000 Subject: [PATCH] Bug 204682 - do not allow document.domain to be set to the empty string. r=heikki, sr=darin, a=blizzard --- content/html/document/src/nsHTMLDocument.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 4262bf3dc5a..8dc9cb9032b 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -1945,6 +1945,8 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain) // 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, // but not to ar.com, baz.com, or fi.foo.bar.com. + if (aDomain.IsEmpty()) + return NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN; nsAutoString current; if (NS_FAILED(GetDomain(current))) return NS_ERROR_FAILURE; @@ -1956,7 +1958,7 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain) current.Right(suffix, aDomain.Length()); PRUnichar c = current.CharAt(current.Length() - aDomain.Length() - 1); if (suffix.Equals(aDomain, nsCaseInsensitiveStringComparator()) && - (c == '.' || c == '/')) + (c == '.')) ok = PR_TRUE; } if (!ok) {