[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser/esr24] bug 967341 - uri management r=honzab a=sylvestre
commit 6a5a507221409dcf7c0e530dc00df4f414d21b46
Author: Patrick McManus <mcmanus@xxxxxxxxxxxx>
Date: Tue Feb 4 11:55:02 2014 -0500
bug 967341 - uri management r=honzab a=sylvestre
---
netwerk/base/src/nsStandardURL.cpp | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp
index 16a001c..2216580 100644
--- a/netwerk/base/src/nsStandardURL.cpp
+++ b/netwerk/base/src/nsStandardURL.cpp
@@ -351,6 +351,7 @@ nsStandardURL::Clear()
mPort = -1;
+ mScheme.Reset();
mAuthority.Reset();
mUsername.Reset();
mPassword.Reset();
@@ -1132,11 +1133,16 @@ nsStandardURL::SetSpec(const nsACString &input)
// parse the given URL...
nsresult rv = ParseURL(spec, specLength);
- if (NS_FAILED(rv)) return rv;
+ if (NS_SUCCEEDED(rv)) {
+ // finally, use the URLSegment member variables to build a normalized
+ // copy of |spec|
+ rv = BuildNormalizedSpec(spec);
+ }
- // finally, use the URLSegment member variables to build a normalized
- // copy of |spec|
- rv = BuildNormalizedSpec(spec);
+ if (NS_FAILED(rv)) {
+ Clear();
+ return rv;
+ }
#if defined(PR_LOGGING)
if (LOG_ENABLED()) {
@@ -1169,16 +1175,16 @@ nsStandardURL::SetScheme(const nsACString &input)
LOG(("nsStandardURL::SetScheme [scheme=%s]\n", scheme.get()));
if (scheme.IsEmpty()) {
- NS_ERROR("cannot remove the scheme from an url");
+ NS_WARNING("cannot remove the scheme from an url");
return NS_ERROR_UNEXPECTED;
}
if (mScheme.mLen < 0) {
- NS_ERROR("uninitialized");
+ NS_WARNING("uninitialized");
return NS_ERROR_NOT_INITIALIZED;
}
if (!net_IsValidScheme(scheme)) {
- NS_ERROR("the given url scheme contains invalid characters");
+ NS_WARNING("the given url scheme contains invalid characters");
return NS_ERROR_UNEXPECTED;
}
@@ -1211,11 +1217,11 @@ nsStandardURL::SetUserPass(const nsACString &input)
if (mURLType == URLTYPE_NO_AUTHORITY) {
if (userpass.IsEmpty())
return NS_OK;
- NS_ERROR("cannot set user:pass on no-auth url");
+ NS_WARNING("cannot set user:pass on no-auth url");
return NS_ERROR_UNEXPECTED;
}
if (mAuthority.mLen < 0) {
- NS_ERROR("uninitialized");
+ NS_WARNING("uninitialized");
return NS_ERROR_NOT_INITIALIZED;
}
@@ -1312,7 +1318,7 @@ nsStandardURL::SetUsername(const nsACString &input)
if (mURLType == URLTYPE_NO_AUTHORITY) {
if (username.IsEmpty())
return NS_OK;
- NS_ERROR("cannot set username on no-auth url");
+ NS_WARNING("cannot set username on no-auth url");
return NS_ERROR_UNEXPECTED;
}
@@ -1357,11 +1363,11 @@ nsStandardURL::SetPassword(const nsACString &input)
if (mURLType == URLTYPE_NO_AUTHORITY) {
if (password.IsEmpty())
return NS_OK;
- NS_ERROR("cannot set password on no-auth url");
+ NS_WARNING("cannot set password on no-auth url");
return NS_ERROR_UNEXPECTED;
}
if (mUsername.mLen <= 0) {
- NS_ERROR("cannot set password without existing username");
+ NS_WARNING("cannot set password without existing username");
return NS_ERROR_FAILURE;
}
@@ -1783,7 +1789,7 @@ nsStandardURL::Resolve(const nsACString &in, nsACString &out)
// initialize a nsStandardURL object.
if (mScheme.mLen < 0) {
- NS_ERROR("unable to Resolve URL: this URL not initialized");
+ NS_WARNING("unable to Resolve URL: this URL not initialized");
return NS_ERROR_NOT_INITIALIZED;
}
@@ -2483,12 +2489,12 @@ nsStandardURL::EnsureFile()
// Parse the spec if we don't have a cached result
if (mSpec.IsEmpty()) {
- NS_ERROR("url not initialized");
+ NS_WARNING("url not initialized");
return NS_ERROR_NOT_INITIALIZED;
}
if (!SegmentIs(mScheme, "file")) {
- NS_ERROR("not a file URL");
+ NS_WARNING("not a file URL");
return NS_ERROR_FAILURE;
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits