Bug 1433958 - Change code that sets nsIURI.userPass to use nsIURIMutator r=mayhemer
* Code in XMLHttpRequestMainThread is converted to set the username and password individually. This is because when the parameters are empty, it ended up calling SetUserPass(":") which always returns an error.
MozReview-Commit-ID: 3cK5HeyzjFE
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURIMutator.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsStringStream.h"
|
||||
@@ -1483,15 +1484,12 @@ XMLHttpRequestMainThread::Open(const nsACString& aMethod,
|
||||
nsAutoCString host;
|
||||
parsedURL->GetHost(host);
|
||||
if (!host.IsEmpty()) {
|
||||
nsAutoCString userpass;
|
||||
if (!aUsername.IsVoid()) {
|
||||
CopyUTF16toUTF8(aUsername, userpass);
|
||||
if (!aUsername.IsVoid() || !aPassword.IsVoid()) {
|
||||
Unused << NS_MutateURI(parsedURL)
|
||||
.SetUsername(NS_ConvertUTF16toUTF8(aUsername))
|
||||
.SetPassword(NS_ConvertUTF16toUTF8(aPassword))
|
||||
.Finalize(parsedURL);
|
||||
}
|
||||
userpass.AppendLiteral(":");
|
||||
if (!aPassword.IsVoid()) {
|
||||
AppendUTF16toUTF8(aPassword, userpass);
|
||||
}
|
||||
parsedURL->SetUserPass(userpass);
|
||||
}
|
||||
|
||||
// Step 9
|
||||
|
||||
Reference in New Issue
Block a user