diff options
-rw-r--r-- | dom/base/nsLocation.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/dom/base/nsLocation.cpp b/dom/base/nsLocation.cpp index faa3e6e7c..039a677e1 100644 --- a/dom/base/nsLocation.cpp +++ b/dom/base/nsLocation.cpp @@ -392,6 +392,10 @@ nsLocation::GetHost(nsAString& aHost) NS_IMETHODIMP nsLocation::SetHost(const nsAString& aHost) { + if (aHost.IsEmpty()) { + return NS_OK; // Ignore empty string + } + if (!CallerSubsumes()) return NS_ERROR_DOM_SECURITY_ERR; @@ -429,6 +433,10 @@ nsLocation::GetHostname(nsAString& aHostname) NS_IMETHODIMP nsLocation::SetHostname(const nsAString& aHostname) { + if (aHostname.IsEmpty()) { + return NS_OK; // Ignore empty string + } + if (!CallerSubsumes()) return NS_ERROR_DOM_SECURITY_ERR; @@ -518,6 +526,10 @@ nsresult nsLocation::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase, bool aReplace) { + if (aHref.IsEmpty()) { + return NS_OK; // Ignore empty string + } + nsresult result; nsCOMPtr<nsIURI> newUri; @@ -726,6 +738,10 @@ nsLocation::GetProtocol(nsAString& aProtocol) NS_IMETHODIMP nsLocation::SetProtocol(const nsAString& aProtocol) { + if (aProtocol.IsEmpty()) { + return NS_OK; // Ignore empty string + } + if (!CallerSubsumes()) return NS_ERROR_DOM_SECURITY_ERR; @@ -882,6 +898,10 @@ nsLocation::GetSearch(nsAString& aSearch) NS_IMETHODIMP nsLocation::SetSearch(const nsAString& aSearch) { + if (aSearch.IsEmpty()) { + return NS_OK; // Ignore empty string + } + nsresult rv = SetSearchInternal(aSearch); if (NS_FAILED(rv)) { return rv; |