mirror of
https://github.com/classilla/tenfourfox.git
synced 2025-01-16 17:31:17 +00:00
M1328894
This commit is contained in:
parent
e504fccb43
commit
4cdf9315ae
@ -33,6 +33,7 @@
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
#include "ScriptSettings.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/dom/LocationBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -691,9 +692,16 @@ nsLocation::SetProtocol(const nsAString& aProtocol)
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol));
|
||||
nsAString::const_iterator start, end;
|
||||
aProtocol.BeginReading(start);
|
||||
aProtocol.EndReading(end);
|
||||
nsAstring::const_iterator iter(start);
|
||||
Unused << FindCharInReadable(':', iter, end);
|
||||
rv = uri->SetScheme(NS_ConvertUTF16toUTF8(Substring(start, iter)));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
// Oh, I wish nsStandardURL returned NS_ERROR_MALFORMED_URI for _all_ the
|
||||
// malformed cases, not just some of them!
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
nsAutoCString newSpec;
|
||||
rv = uri->GetSpec(newSpec);
|
||||
@ -703,9 +711,29 @@ nsLocation::SetProtocol(const nsAString& aProtocol)
|
||||
// We may want a new URI class for the new URI, so recreate it:
|
||||
rv = NS_NewURI(getter_AddRefs(uri), newSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (rv == NS_ERROR_MALFORMED_URI) {
|
||||
rv = NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool isHttp;
|
||||
rv = uri->SchemeIs("http", &isHttp);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool isHttps;
|
||||
rv = uri->SchemeIs("https", &isHttps);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!isHttp && !isHttps) {
|
||||
// No-op, per spec.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return SetURI(uri);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user