зеркало из https://github.com/mozilla/pjs.git
Fix bug 409885: don't do string-manipulation to set the domain on a URI.
r+sr+a=jst
This commit is contained in:
Родитель
32c8e5b94f
Коммит
504fbeb90f
|
@ -1718,20 +1718,16 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCAutoString newURIString;
|
||||
if (NS_FAILED(uri->GetScheme(newURIString)))
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCAutoString path;
|
||||
if (NS_FAILED(uri->GetPath(path)))
|
||||
return NS_ERROR_FAILURE;
|
||||
newURIString.AppendLiteral("://");
|
||||
AppendUTF16toUTF8(aDomain, newURIString);
|
||||
newURIString.Append(path);
|
||||
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
if (NS_FAILED(NS_NewURI(getter_AddRefs(newURI), newURIString)))
|
||||
return NS_ERROR_FAILURE;
|
||||
nsresult rv = uri->Clone(getter_AddRefs(newURI));
|
||||
NS_ENSURE_TRUE(newURI, rv);
|
||||
|
||||
rv = newURI->SetUserPass(EmptyCString());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = newURI->SetHostPort(NS_ConvertUTF16toUTF8(aDomain));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// 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.
|
||||
|
@ -1762,6 +1758,7 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain)
|
|||
return NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN;
|
||||
}
|
||||
|
||||
NS_TryToSetImmutable(newURI);
|
||||
return NodePrincipal()->SetDomain(newURI);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче