summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPale Moon <git-repo@palemoon.org>2018-06-24 13:40:50 +0200
committerPale Moon <git-repo@palemoon.org>2018-06-24 13:40:50 +0200
commit53606d9e9d107c5992b1b86932d30e9af7878b4c (patch)
tree71fba9ee020d1734f1b1356542d0e1acfd9dc9fd
parent1ffd7ba7ac061d94f2cdd3c99dde954cebd5376b (diff)
downloadpalemoon-gre-53606d9e9d107c5992b1b86932d30e9af7878b4c.tar.gz
Prevent various location-based hazards.
-rw-r--r--dom/base/nsLocation.cpp20
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;