diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-06-24 13:41:23 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-06-24 13:41:23 +0200 |
commit | 574156323b4fb817c1eb62f442b4e3cbdec9067b (patch) | |
tree | 0145cc819d86b16d9242df0395025cc8ed7a6aa6 /dom | |
parent | 83be316ca4f669e2e72d2afa7bb74bdddf085b68 (diff) | |
download | UXP-574156323b4fb817c1eb62f442b4e3cbdec9067b.tar UXP-574156323b4fb817c1eb62f442b4e3cbdec9067b.tar.gz UXP-574156323b4fb817c1eb62f442b4e3cbdec9067b.tar.lz UXP-574156323b4fb817c1eb62f442b4e3cbdec9067b.tar.xz UXP-574156323b4fb817c1eb62f442b4e3cbdec9067b.zip |
Prevent various location-based hazards.
Diffstat (limited to 'dom')
-rw-r--r-- | dom/base/Location.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/dom/base/Location.cpp b/dom/base/Location.cpp index b6b95aaa6..7b3722f09 100644 --- a/dom/base/Location.cpp +++ b/dom/base/Location.cpp @@ -393,6 +393,10 @@ Location::GetHost(nsAString& aHost) NS_IMETHODIMP Location::SetHost(const nsAString& aHost) { + if (aHost.IsEmpty()) { + return NS_OK; // Ignore empty string + } + nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (NS_WARN_IF(NS_FAILED(rv) || !uri)) { @@ -424,6 +428,10 @@ Location::GetHostname(nsAString& aHostname) NS_IMETHODIMP Location::SetHostname(const nsAString& aHostname) { + if (aHostname.IsEmpty()) { + return NS_OK; // Ignore empty string + } + nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (NS_WARN_IF(NS_FAILED(rv) || !uri)) { @@ -507,6 +515,10 @@ nsresult Location::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase, bool aReplace) { + if (aHref.IsEmpty()) { + return NS_OK; // Ignore empty string + } + nsresult result; nsCOMPtr<nsIURI> newUri; @@ -694,6 +706,10 @@ Location::GetProtocol(nsAString& aProtocol) NS_IMETHODIMP Location::SetProtocol(const nsAString& aProtocol) { + if (aProtocol.IsEmpty()) { + return NS_OK; // Ignore empty string + } + nsCOMPtr<nsIURI> uri; nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (NS_WARN_IF(NS_FAILED(rv) || !uri)) { @@ -747,6 +763,10 @@ Location::GetSearch(nsAString& aSearch) NS_IMETHODIMP Location::SetSearch(const nsAString& aSearch) { + if (aSearch.IsEmpty()) { + return NS_OK; // Ignore empty string + } + nsresult rv = SetSearchInternal(aSearch); if (NS_FAILED(rv)) { return rv; |