diff --git a/dom/src/base/nsLocation.cpp b/dom/src/base/nsLocation.cpp index a3e7422a03d..ad9d8c20f76 100644 --- a/dom/src/base/nsLocation.cpp +++ b/dom/src/base/nsLocation.cpp @@ -57,7 +57,6 @@ #include "nsCOMPtr.h" #include "nsEscape.h" #include "nsJSUtils.h" -#include "nsIScriptSecurityManager.h" #include "nsIDOMWindow.h" #include "nsIDOMDocument.h" #include "nsIDocument.h" @@ -428,18 +427,17 @@ NS_IMETHODIMP nsLocation::SetHash(const nsAString& aHash) { nsCOMPtr uri; - nsresult result = NS_OK; - - result = GetWritableURI(getter_AddRefs(uri)); + nsresult rv = GetWritableURI(getter_AddRefs(uri)); nsCOMPtr url(do_QueryInterface(uri)); - if (url) { - url->SetRef(NS_ConvertUTF16toUTF8(aHash)); - SetURI(url); + rv = url->SetRef(NS_ConvertUTF16toUTF8(aHash)); + if (NS_SUCCEEDED(rv)) { + SetURI(url); + } } - return result; + return rv; } NS_IMETHODIMP @@ -469,16 +467,16 @@ NS_IMETHODIMP nsLocation::SetHost(const nsAString& aHost) { nsCOMPtr uri; - nsresult result; - - result = GetWritableURI(getter_AddRefs(uri)); + nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (uri) { - uri->SetHostPort(NS_ConvertUTF16toUTF8(aHost)); - SetURI(uri); + rv = uri->SetHostPort(NS_ConvertUTF16toUTF8(aHost)); + if (NS_SUCCEEDED(rv)) { + SetURI(uri); + } } - return result; + return rv; } NS_IMETHODIMP @@ -508,16 +506,16 @@ NS_IMETHODIMP nsLocation::SetHostname(const nsAString& aHostname) { nsCOMPtr uri; - nsresult result; - - result = GetWritableURI(getter_AddRefs(uri)); + nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (uri) { - uri->SetHost(NS_ConvertUTF16toUTF8(aHostname)); - SetURI(uri); + rv = uri->SetHost(NS_ConvertUTF16toUTF8(aHostname)); + if (NS_SUCCEEDED(rv)) { + SetURI(uri); + } } - return result; + return rv; } NS_IMETHODIMP @@ -687,16 +685,16 @@ NS_IMETHODIMP nsLocation::SetPathname(const nsAString& aPathname) { nsCOMPtr uri; - nsresult result = NS_OK; - - result = GetWritableURI(getter_AddRefs(uri)); + nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (uri) { - uri->SetPath(NS_ConvertUTF16toUTF8(aPathname)); - SetURI(uri); + rv = uri->SetPath(NS_ConvertUTF16toUTF8(aPathname)); + if (NS_SUCCEEDED(rv)) { + SetURI(uri); + } } - return result; + return rv; } NS_IMETHODIMP @@ -730,9 +728,7 @@ NS_IMETHODIMP nsLocation::SetPort(const nsAString& aPort) { nsCOMPtr uri; - nsresult result = NS_OK; - - result = GetWritableURI(getter_AddRefs(uri)); + nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (uri) { // perhaps use nsReadingIterators at some point? @@ -749,11 +745,13 @@ nsLocation::SetPort(const nsAString& aPort) } } - uri->SetPort(port); - SetURI(uri); + rv = uri->SetPort(port); + if (NS_SUCCEEDED(rv)) { + SetURI(uri); + } } - return result; + return rv; } NS_IMETHODIMP @@ -784,16 +782,16 @@ NS_IMETHODIMP nsLocation::SetProtocol(const nsAString& aProtocol) { nsCOMPtr uri; - nsresult result = NS_OK; - - result = GetWritableURI(getter_AddRefs(uri)); + nsresult rv = GetWritableURI(getter_AddRefs(uri)); if (uri) { - uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol)); - SetURI(uri); + rv = uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol)); + if (NS_SUCCEEDED(rv)) { + SetURI(uri); + } } - return result; + return rv; } NS_IMETHODIMP @@ -826,17 +824,17 @@ NS_IMETHODIMP nsLocation::SetSearch(const nsAString& aSearch) { nsCOMPtr uri; - nsresult result = NS_OK; - - result = GetWritableURI(getter_AddRefs(uri)); + nsresult rv = GetWritableURI(getter_AddRefs(uri)); nsCOMPtr url(do_QueryInterface(uri)); if (url) { - result = url->SetQuery(NS_ConvertUTF16toUTF8(aSearch)); - SetURI(uri); + rv = url->SetQuery(NS_ConvertUTF16toUTF8(aSearch)); + if (NS_SUCCEEDED(rv)) { + SetURI(uri); + } } - return result; + return rv; } NS_IMETHODIMP diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp index 6a8974336a1..385c0e1bdfb 100644 --- a/netwerk/base/src/nsStandardURL.cpp +++ b/netwerk/base/src/nsStandardURL.cpp @@ -1425,7 +1425,7 @@ nsStandardURL::SetHost(const nsACString &input) if (mURLType == URLTYPE_NO_AUTHORITY) { if (flat.IsEmpty()) return NS_OK; - NS_ERROR("cannot set host on no-auth url"); + NS_WARNING("cannot set host on no-auth url"); return NS_ERROR_UNEXPECTED; } @@ -1499,7 +1499,7 @@ nsStandardURL::SetPort(PRInt32 port) return NS_OK; if (mURLType == URLTYPE_NO_AUTHORITY) { - NS_ERROR("cannot set port on no-auth url"); + NS_WARNING("cannot set port on no-auth url"); return NS_ERROR_UNEXPECTED; }