Bug 1945924 - Replace SchemeIsFoo functions with the inlined SchemeIs() call. r=valentin,emilio,necko-reviewers,geckoview-reviewers,anti-tracking-reviewers,core-sessionstore-reviewers,ohall,farre
No behavior change intended. Differential Revision: https://phabricator.services.mozilla.com/D236756
This commit is contained in:
@@ -231,8 +231,8 @@ uint32_t nsScriptSecurityManager::SecurityHashURI(nsIURI* aURI) {
|
||||
|
||||
bool nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(nsIURI* aUriA,
|
||||
nsIURI* aUriB) {
|
||||
if (!aUriA || (!net::SchemeIsHTTP(aUriA) && !net::SchemeIsHTTPS(aUriA)) ||
|
||||
!aUriB || (!net::SchemeIsHTTP(aUriB) && !net::SchemeIsHTTPS(aUriB))) {
|
||||
if (!aUriA || !net::SchemeIsHttpOrHttps(aUriA) || !aUriB ||
|
||||
!net::SchemeIsHttpOrHttps(aUriB)) {
|
||||
return false;
|
||||
}
|
||||
if (!SecurityCompareURIs(aUriA, aUriB)) {
|
||||
|
||||
@@ -2040,7 +2040,7 @@ nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState,
|
||||
|
||||
const auto& sourceBC = aLoadState->SourceBrowsingContext();
|
||||
|
||||
if (net::SchemeIsJavascript(aLoadState->URI())) {
|
||||
if (aLoadState->URI()->SchemeIs("javascript")) {
|
||||
if (!XRE_IsParentProcess()) {
|
||||
// Web content should only be able to load javascript: URIs into documents
|
||||
// whose principals the caller principal subsumes, which by definition
|
||||
@@ -2135,7 +2135,7 @@ nsresult BrowsingContext::InternalLoad(nsDocShellLoadState* aLoadState) {
|
||||
|
||||
const auto& sourceBC = aLoadState->SourceBrowsingContext();
|
||||
|
||||
if (net::SchemeIsJavascript(aLoadState->URI())) {
|
||||
if (aLoadState->URI()->SchemeIs("javascript")) {
|
||||
if (!XRE_IsParentProcess()) {
|
||||
// Web content should only be able to load javascript: URIs into documents
|
||||
// whose principals the caller principal subsumes, which by definition
|
||||
|
||||
@@ -2398,18 +2398,18 @@ bool CanonicalBrowsingContext::SupportsLoadingInParent(
|
||||
// DocumentChannel currently only supports connecting channels into the
|
||||
// content process, so we can only support schemes that will always be loaded
|
||||
// there for now. Restrict to just http(s) for simplicity.
|
||||
if (!net::SchemeIsHTTP(aLoadState->URI()) &&
|
||||
!net::SchemeIsHTTPS(aLoadState->URI())) {
|
||||
if (!net::SchemeIsHttpOrHttps(aLoadState->URI())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (WindowGlobalParent* global = GetCurrentWindowGlobal()) {
|
||||
nsCOMPtr<nsIURI> currentURI = global->GetDocumentURI();
|
||||
if (currentURI) {
|
||||
nsCOMPtr<nsIURI> uri = aLoadState->URI();
|
||||
bool newURIHasRef = false;
|
||||
aLoadState->URI()->GetHasRef(&newURIHasRef);
|
||||
uri->GetHasRef(&newURIHasRef);
|
||||
bool equalsExceptRef = false;
|
||||
aLoadState->URI()->EqualsExceptRef(currentURI, &equalsExceptRef);
|
||||
uri->EqualsExceptRef(currentURI, &equalsExceptRef);
|
||||
|
||||
if (equalsExceptRef && newURIHasRef) {
|
||||
// This navigation is same-doc WRT the current one, we should pass it
|
||||
@@ -2454,7 +2454,7 @@ bool CanonicalBrowsingContext::LoadInParent(nsDocShellLoadState* aLoadState,
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!net::SchemeIsJavascript(aLoadState->URI()));
|
||||
MOZ_ASSERT(!aLoadState->URI()->SchemeIs("javascript"));
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(
|
||||
SetParentInitiatedNavigationEpoch(++gParentInitiatedNavigationEpoch));
|
||||
|
||||
@@ -667,7 +667,7 @@ nsDocShell::SetCancelContentJSEpoch(int32_t aEpoch) {
|
||||
|
||||
nsresult nsDocShell::CheckDisallowedJavascriptLoad(
|
||||
nsDocShellLoadState* aLoadState) {
|
||||
if (!net::SchemeIsJavascript(aLoadState->URI())) {
|
||||
if (!aLoadState->URI()->SchemeIs("javascript")) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1616,8 +1616,8 @@ nsDocShell::ForceEncodingDetection() {
|
||||
|
||||
mForcedAutodetection = true;
|
||||
|
||||
nsIURI* url = doc->GetOriginalURI();
|
||||
bool isFileURL = url && SchemeIsFile(url);
|
||||
nsIURI* uri = doc->GetOriginalURI();
|
||||
bool isFileURL = uri && uri->SchemeIs("file");
|
||||
|
||||
int32_t charsetSource = doc->GetDocumentCharacterSetSource();
|
||||
auto encoding = doc->GetDocumentCharacterSet();
|
||||
@@ -3710,7 +3710,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
||||
if (aURI) {
|
||||
// displaying "file://" is aesthetically unpleasing and could even be
|
||||
// confusing to the user
|
||||
if (SchemeIsFile(aURI)) {
|
||||
if (aURI->SchemeIs("file")) {
|
||||
aURI->GetPathQueryRef(spec);
|
||||
} else {
|
||||
aURI->GetSpec(spec);
|
||||
@@ -3740,7 +3740,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
||||
NS_ENSURE_FALSE(messageStr.IsEmpty(), NS_ERROR_FAILURE);
|
||||
|
||||
if ((NS_ERROR_NET_INTERRUPT == aError || NS_ERROR_NET_RESET == aError) &&
|
||||
SchemeIsHTTPS(aURI)) {
|
||||
aURI->SchemeIs("https")) {
|
||||
// Maybe TLS intolerant. Treat this as an SSL error.
|
||||
error = "nssFailure2";
|
||||
}
|
||||
@@ -5780,7 +5780,7 @@ already_AddRefed<nsIURI> nsDocShell::MaybeFixBadCertDomainErrorURI(
|
||||
}
|
||||
|
||||
// Return if scheme is not HTTPS.
|
||||
if (!SchemeIsHTTPS(aUrl)) {
|
||||
if (!aUrl->SchemeIs("https")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -5949,10 +5949,8 @@ already_AddRefed<nsIURI> nsDocShell::AttemptURIFixup(
|
||||
// Someone needs to clean up keywords in general so we can
|
||||
// determine on a per url basis if we want keywords
|
||||
// enabled...this is just a bandaid...
|
||||
nsAutoCString scheme;
|
||||
Unused << url->GetScheme(scheme);
|
||||
if (Preferences::GetBool("keyword.enabled", false) &&
|
||||
StringBeginsWith(scheme, "http"_ns)) {
|
||||
net::SchemeIsHttpOrHttps(url)) {
|
||||
bool attemptFixup = false;
|
||||
nsAutoCString host;
|
||||
Unused << url->GetHost(host);
|
||||
@@ -6050,7 +6048,7 @@ already_AddRefed<nsIURI> nsDocShell::AttemptURIFixup(
|
||||
} else if (aStatus == NS_ERROR_CONNECTION_REFUSED &&
|
||||
Preferences::GetBool("browser.fixup.fallback-to-https", false)) {
|
||||
// Try HTTPS, since http didn't work
|
||||
if (SchemeIsHTTP(url)) {
|
||||
if (url->SchemeIs("http")) {
|
||||
int32_t port = 0;
|
||||
url->GetPort(&port);
|
||||
|
||||
@@ -9309,7 +9307,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
|
||||
MOZ_DIAGNOSTIC_ASSERT(aLoadState->LoadType() == LOAD_NORMAL);
|
||||
|
||||
// Disallow external chrome: loads targetted at content windows
|
||||
if (SchemeIsChrome(aLoadState->URI())) {
|
||||
if (aLoadState->URI()->SchemeIs("chrome")) {
|
||||
NS_WARNING("blocked external chrome: url -- use '--chrome' option");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -9353,7 +9351,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
|
||||
|
||||
// XXXbz mTiming should know what channel it's for, so we don't
|
||||
// need this hackery.
|
||||
const bool isJavaScript = SchemeIsJavascript(aLoadState->URI());
|
||||
const bool isJavaScript = aLoadState->URI()->SchemeIs("javascript");
|
||||
const bool isExternalProtocol =
|
||||
nsContentUtils::IsExternalProtocol(aLoadState->URI());
|
||||
const bool isDownload = !aLoadState->FileName().IsVoid();
|
||||
@@ -9733,7 +9731,7 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
|
||||
MOZ_ALWAYS_SUCCEEDS(vsc->SetBaseURI(aBaseURI));
|
||||
}
|
||||
}
|
||||
} else if (SchemeIsViewSource(aURI)) {
|
||||
} else if (aURI->SchemeIs("view-source")) {
|
||||
// Instantiate view source handler protocol, if it doesn't exist already.
|
||||
nsCOMPtr<nsIIOService> io(do_GetIOService());
|
||||
MOZ_ASSERT(io);
|
||||
@@ -10239,7 +10237,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
|
||||
while (nestedURI) {
|
||||
// view-source should always be an nsINestedURI, loop and check the
|
||||
// scheme on this and all inner URIs that are also nested URIs.
|
||||
if (SchemeIsViewSource(tempURI)) {
|
||||
if (tempURI->SchemeIs("view-source")) {
|
||||
return NS_ERROR_UNKNOWN_PROTOCOL;
|
||||
}
|
||||
nestedURI->GetInnerURI(getter_AddRefs(tempURI));
|
||||
@@ -10256,20 +10254,21 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
|
||||
// configured as unique opaque origin.
|
||||
bool inheritPrincipal = false;
|
||||
|
||||
nsCOMPtr<nsIURI> uri = aLoadState->URI();
|
||||
if (aLoadState->PrincipalToInherit()) {
|
||||
bool isSrcdoc =
|
||||
aLoadState->HasInternalLoadFlags(INTERNAL_LOAD_FLAGS_IS_SRCDOC);
|
||||
bool inheritAttrs = nsContentUtils::ChannelShouldInheritPrincipal(
|
||||
aLoadState->PrincipalToInherit(), aLoadState->URI(),
|
||||
aLoadState->PrincipalToInherit(), uri,
|
||||
true, // aInheritForAboutBlank
|
||||
isSrcdoc);
|
||||
|
||||
inheritPrincipal = inheritAttrs && !SchemeIsData(aLoadState->URI());
|
||||
inheritPrincipal = inheritAttrs && !uri->SchemeIs("data");
|
||||
}
|
||||
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1736570
|
||||
const bool isAboutBlankLoadOntoInitialAboutBlank =
|
||||
IsAboutBlankLoadOntoInitialAboutBlank(aLoadState->URI(), inheritPrincipal,
|
||||
IsAboutBlankLoadOntoInitialAboutBlank(uri, inheritPrincipal,
|
||||
aLoadState->PrincipalToInherit());
|
||||
|
||||
// FIXME We still have a ton of codepaths that don't pass through
|
||||
@@ -10282,7 +10281,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
|
||||
// Materialize LoadingSessionHistoryInfo here, because DocumentChannel
|
||||
// loads have it, and later history behavior depends on it existing.
|
||||
UniquePtr<SessionHistoryInfo> entry = MakeUnique<SessionHistoryInfo>(
|
||||
aLoadState->URI(), aLoadState->TriggeringPrincipal(),
|
||||
uri, aLoadState->TriggeringPrincipal(),
|
||||
aLoadState->PrincipalToInherit(),
|
||||
aLoadState->PartitionedPrincipalToInherit(), aLoadState->Csp(),
|
||||
mContentTypeHint);
|
||||
@@ -10394,8 +10393,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
|
||||
aLoadState->GetLoadIdentifier());
|
||||
RefPtr<LoadInfo> loadInfo =
|
||||
(contentPolicyType == nsIContentPolicy::TYPE_DOCUMENT)
|
||||
? new LoadInfo(loadingWindow, aLoadState->URI(),
|
||||
aLoadState->TriggeringPrincipal(),
|
||||
? new LoadInfo(loadingWindow, uri, aLoadState->TriggeringPrincipal(),
|
||||
topLevelLoadingContext, securityFlags, sandboxFlags)
|
||||
: new LoadInfo(loadingPrincipal, aLoadState->TriggeringPrincipal(),
|
||||
loadingNode, securityFlags, contentPolicyType,
|
||||
@@ -10502,7 +10500,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
|
||||
mBrowsingContext, uriModified, Some(isEmbeddingBlockedError));
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
if (DocumentChannel::CanUseDocumentChannel(aLoadState->URI()) &&
|
||||
if (DocumentChannel::CanUseDocumentChannel(uri) &&
|
||||
!isAboutBlankLoadOntoInitialAboutBlank) {
|
||||
channel = DocumentChannel::CreateForDocument(
|
||||
aLoadState, loadInfo, loadFlags, this, cacheKey, uriModified,
|
||||
@@ -12065,7 +12063,7 @@ nsresult nsDocShell::LoadHistoryEntry(nsDocShellLoadState* aLoadState,
|
||||
aLoadState->SetLoadType(aLoadType);
|
||||
|
||||
nsresult rv;
|
||||
if (SchemeIsJavascript(aLoadState->URI())) {
|
||||
if (aLoadState->URI()->SchemeIs("javascript")) {
|
||||
// We're loading a URL that will execute script from inside asyncOpen.
|
||||
// Replace the current document with about:blank now to prevent
|
||||
// anything from the current document from leaking into any JavaScript
|
||||
@@ -12908,7 +12906,7 @@ nsresult nsDocShell::OnLinkClick(
|
||||
bool nsDocShell::ShouldOpenInBlankTarget(const nsAString& aOriginalTarget,
|
||||
nsIURI* aLinkURI, nsIContent* aContent,
|
||||
bool aIsUserTriggered) {
|
||||
if (net::SchemeIsJavascript(aLinkURI)) {
|
||||
if (aLinkURI->SchemeIs("javascript")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ static void ForEachPing(nsIContent* aContent, ForEachPingCallback aCallback,
|
||||
continue;
|
||||
}
|
||||
// Explicitly not allow loading data: URIs
|
||||
if (!net::SchemeIsData(uri)) {
|
||||
if (!uri->SchemeIs("data")) {
|
||||
aCallback(aClosure, aContent, uri, ios);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -826,7 +826,7 @@ EventSourceImpl::AsyncOnChannelRedirect(
|
||||
rv = NS_GetFinalChannelURI(aNewChannel, getter_AddRefs(newURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool isValidScheme = newURI->SchemeIs("http") || newURI->SchemeIs("https");
|
||||
bool isValidScheme = net::SchemeIsHttpOrHttps(newURI);
|
||||
|
||||
rv =
|
||||
mIsMainThread ? GetEventSource()->CheckCurrentGlobalCorrectness() : NS_OK;
|
||||
@@ -988,7 +988,7 @@ nsresult EventSourceImpl::InitChannelAndRequestEventSource(
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
bool isValidScheme = mSrc->SchemeIs("http") || mSrc->SchemeIs("https");
|
||||
bool isValidScheme = net::SchemeIsHttpOrHttps(mSrc);
|
||||
|
||||
MOZ_ASSERT_IF(mIsMainThread, aEventTargetAccessAllowed);
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ void Location::SetProtocol(const nsACString& aProtocol,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uri->SchemeIs("http") && !uri->SchemeIs("https")) {
|
||||
if (!net::SchemeIsHttpOrHttps(uri)) {
|
||||
// No-op, per spec.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ void LocationBase::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
||||
rv = bc->LoadURI(loadState);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
if (rv == NS_ERROR_DOM_BAD_CROSS_ORIGIN_URI &&
|
||||
net::SchemeIsJavascript(loadState->URI())) {
|
||||
loadState->URI()->SchemeIs("javascript")) {
|
||||
// Per spec[1], attempting to load a javascript: URI into a cross-origin
|
||||
// BrowsingContext is a no-op, and should not raise an exception.
|
||||
// Technically, Location setters run with exceptions enabled should only
|
||||
|
||||
@@ -1236,7 +1236,7 @@ bool Navigator::SendBeaconInternal(const nsAString& aUrl,
|
||||
}
|
||||
|
||||
// Spec disallows any schemes save for HTTP/HTTPs
|
||||
if (!uri->SchemeIs("http") && !uri->SchemeIs("https")) {
|
||||
if (!net::SchemeIsHttpOrHttps(uri)) {
|
||||
aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>("Beacon",
|
||||
uri->GetSpecOrDefault());
|
||||
return false;
|
||||
|
||||
@@ -455,7 +455,7 @@ ThirdPartyUtil::GetBaseDomain(nsIURI* aHostURI, nsACString& aBaseDomain) {
|
||||
|
||||
// The aHostURI can be a view-source URI, in which case we need to get the
|
||||
// base domain from the inner most URI.
|
||||
if (net::SchemeIsViewSource(aHostURI)) {
|
||||
if (aHostURI->SchemeIs("view-source")) {
|
||||
rv = NS_GetInnermostURIHost(aHostURI, aBaseDomain);
|
||||
} else {
|
||||
rv = aHostURI->GetAsciiHost(aBaseDomain);
|
||||
|
||||
@@ -7113,8 +7113,8 @@ nsresult nsContentUtils::GetWebExposedOriginSerialization(nsIURI* aURI,
|
||||
|
||||
if (
|
||||
// Schemes in spec. https://url.spec.whatwg.org/#origin
|
||||
!uri->SchemeIs("http") && !uri->SchemeIs("https") &&
|
||||
!uri->SchemeIs("file") && !uri->SchemeIs("resource") &&
|
||||
!net::SchemeIsHttpOrHttps(uri) && !uri->SchemeIs("file") &&
|
||||
!uri->SchemeIs("resource") &&
|
||||
// Our own schemes.
|
||||
!uri->SchemeIs("moz-extension")) {
|
||||
aOrigin.AssignLiteral("null");
|
||||
|
||||
@@ -1402,7 +1402,7 @@ nsresult nsObjectLoadingContent::OpenChannel() {
|
||||
true, // aInheritForAboutBlank
|
||||
false); // aForceInherit
|
||||
|
||||
bool inheritPrincipal = inheritAttrs && !SchemeIsData(mURI);
|
||||
bool inheritPrincipal = inheritAttrs && !mURI->SchemeIs("data");
|
||||
|
||||
nsSecurityFlags securityFlags =
|
||||
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL;
|
||||
|
||||
@@ -1962,7 +1962,7 @@ void IMEStateManager::SetIMEState(const IMEState& aState,
|
||||
// other apps like IME know which one is touched by the user because
|
||||
// malicious text services may like files which are explicitly used
|
||||
// by the user better.
|
||||
if (uri->SchemeIs("http") || uri->SchemeIs("https")) {
|
||||
if (net::SchemeIsHttpOrHttps(uri)) {
|
||||
// Note that we don't need to expose UserPass, Query and Reference to
|
||||
// IME since they may contain sensitive data, but non-malicious text
|
||||
// services must not require these data.
|
||||
|
||||
@@ -3550,8 +3550,7 @@ nsresult BrowserChild::CanCancelContentJS(
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURI> currentURI = entry->GetURI();
|
||||
if (!currentURI->SchemeIs("http") && !currentURI->SchemeIs("https") &&
|
||||
!currentURI->SchemeIs("file")) {
|
||||
if (!net::SchemeIsHttpOrHttps(currentURI) && !currentURI->SchemeIs("file")) {
|
||||
// Only cancel content JS for http(s) and file URIs. Other URIs are probably
|
||||
// internal and we should just let them run to completion.
|
||||
return NS_OK;
|
||||
|
||||
@@ -3746,8 +3746,7 @@ bool BrowserParent::CanCancelContentJS(
|
||||
false);
|
||||
|
||||
nsCOMPtr<nsIURI> currentURI = entry->GetURI();
|
||||
if (!currentURI->SchemeIs("http") && !currentURI->SchemeIs("https") &&
|
||||
!currentURI->SchemeIs("file")) {
|
||||
if (!net::SchemeIsHttpOrHttps(currentURI) && !currentURI->SchemeIs("file")) {
|
||||
// Only cancel content JS for http(s) and file URIs. Other URIs are probably
|
||||
// internal and we should just let them run to completion.
|
||||
return false;
|
||||
|
||||
@@ -332,7 +332,7 @@ mozilla::ipc::IPCResult WindowGlobalParent::RecvLoadURI(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (net::SchemeIsJavascript(aLoadState->URI())) {
|
||||
if (aLoadState->URI()->SchemeIs("javascript")) {
|
||||
return IPC_FAIL(this, "Illegal cross-process javascript: load attempt");
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ mozilla::ipc::IPCResult WindowGlobalParent::RecvInternalLoad(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (net::SchemeIsJavascript(aLoadState->URI())) {
|
||||
if (aLoadState->URI()->SchemeIs("javascript")) {
|
||||
return IPC_FAIL(this, "Illegal cross-process javascript: load attempt");
|
||||
}
|
||||
|
||||
@@ -1372,23 +1372,23 @@ mozilla::ipc::IPCResult WindowGlobalParent::RecvSetDocumentDomain(
|
||||
|
||||
mozilla::ipc::IPCResult WindowGlobalParent::RecvReloadWithHttpsOnlyException() {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> currentUri = BrowsingContext()->Top()->GetCurrentURI();
|
||||
nsCOMPtr<nsIURI> currentURI = BrowsingContext()->Top()->GetCurrentURI();
|
||||
|
||||
if (!currentUri) {
|
||||
if (!currentURI) {
|
||||
return IPC_FAIL(this, "HTTPS-only mode: Failed to get current URI");
|
||||
}
|
||||
|
||||
bool isViewSource = currentUri->SchemeIs("view-source");
|
||||
bool isViewSource = currentURI->SchemeIs("view-source");
|
||||
|
||||
nsCOMPtr<nsINestedURI> nestedURI = do_QueryInterface(currentUri);
|
||||
nsCOMPtr<nsINestedURI> nestedURI = do_QueryInterface(currentURI);
|
||||
nsCOMPtr<nsIURI> innerURI;
|
||||
if (isViewSource) {
|
||||
nestedURI->GetInnerURI(getter_AddRefs(innerURI));
|
||||
} else {
|
||||
innerURI = currentUri;
|
||||
innerURI = currentURI;
|
||||
}
|
||||
|
||||
if (!innerURI->SchemeIs("https") && !innerURI->SchemeIs("http")) {
|
||||
if (!net::SchemeIsHttpOrHttps(innerURI)) {
|
||||
return IPC_FAIL(this, "HTTPS-only mode: Illegal state");
|
||||
}
|
||||
|
||||
@@ -1641,8 +1641,7 @@ void WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
BrowsingContext()->IsTopContent()) {
|
||||
GetContentBlockingLog()->ReportLog();
|
||||
|
||||
if (mDocumentURI && (net::SchemeIsHTTP(mDocumentURI) ||
|
||||
net::SchemeIsHTTPS(mDocumentURI))) {
|
||||
if (mDocumentURI && net::SchemeIsHttpOrHttps(mDocumentURI)) {
|
||||
GetContentBlockingLog()->ReportCanvasFingerprintingLog(
|
||||
DocumentPrincipal());
|
||||
GetContentBlockingLog()->ReportFontFingerprintingLog(
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "mozilla/dom/PrototypeDocumentContentSink.h"
|
||||
#include "nsIParser.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/URL.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
@@ -666,7 +665,7 @@ nsresult PrototypeDocumentContentSink::DoneWalking() {
|
||||
|
||||
StartLayout();
|
||||
|
||||
if (IsChromeURI(mDocumentURI) &&
|
||||
if (mDocumentURI->SchemeIs("chrome") &&
|
||||
nsXULPrototypeCache::GetInstance()->IsEnabled()) {
|
||||
bool isCachedOnDisk;
|
||||
nsXULPrototypeCache::GetInstance()->HasPrototype(mDocumentURI,
|
||||
@@ -733,7 +732,7 @@ nsresult PrototypeDocumentContentSink::LoadScript(
|
||||
// Load a transcluded script
|
||||
nsresult rv;
|
||||
|
||||
bool isChromeDoc = IsChromeURI(mDocumentURI);
|
||||
bool isChromeDoc = mDocumentURI->SchemeIs("chrome");
|
||||
|
||||
if (isChromeDoc && aScriptProto->HasStencil()) {
|
||||
rv = ExecuteScript(aScriptProto);
|
||||
@@ -938,7 +937,8 @@ PrototypeDocumentContentSink::OnScriptCompileComplete(JS::Stencil* aStencil,
|
||||
// the true crime story.)
|
||||
bool useXULCache = nsXULPrototypeCache::GetInstance()->IsEnabled();
|
||||
|
||||
if (useXULCache && IsChromeURI(mDocumentURI) && scriptProto->HasStencil()) {
|
||||
if (useXULCache && mDocumentURI->SchemeIs("chrome") &&
|
||||
scriptProto->HasStencil()) {
|
||||
nsXULPrototypeCache::GetInstance()->PutStencil(scriptProto->mSrcURI,
|
||||
scriptProto->GetStencil());
|
||||
}
|
||||
|
||||
@@ -1005,10 +1005,9 @@ void StripURIForReporting(nsIURI* aSelfURI, nsIURI* aURI,
|
||||
// If the origin of aURI is a globally unique identifier (for example,
|
||||
// aURI has a scheme of data, blob, or filesystem), then
|
||||
// return the ASCII serialization of uri’s scheme.
|
||||
bool isHttpOrWs = (aURI->SchemeIs("http") || aURI->SchemeIs("https") ||
|
||||
aURI->SchemeIs("ws") || aURI->SchemeIs("wss"));
|
||||
bool isWsOrWss = aURI->SchemeIs("ws") || aURI->SchemeIs("wss");
|
||||
|
||||
if (!isHttpOrWs) {
|
||||
if (!net::SchemeIsHttpOrHttps(aURI) && !isWsOrWss) {
|
||||
// not strictly spec compliant, but what we really care about is
|
||||
// http/https. If it's not http/https, then treat aURI
|
||||
// as if it's a globally unique identifier and just return the scheme.
|
||||
@@ -1337,10 +1336,7 @@ nsresult nsCSPContext::SendReportsToURIs(
|
||||
}
|
||||
|
||||
// log a warning to console if scheme is not http or https
|
||||
bool isHttpScheme =
|
||||
reportURI->SchemeIs("http") || reportURI->SchemeIs("https");
|
||||
|
||||
if (!isHttpScheme) {
|
||||
if (!net::SchemeIsHttpOrHttps(reportURI)) {
|
||||
AutoTArray<nsString, 1> params = {reportURIs[r]};
|
||||
logToConsole("reportURInotHttpsOrHttp2", params,
|
||||
NS_ConvertUTF16toUTF8(aViolationEventInit.mSourceFile),
|
||||
|
||||
@@ -98,8 +98,7 @@ bool nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
bool isDataURI = uri->SchemeIs("data");
|
||||
if (!isDataURI) {
|
||||
if (!uri->SchemeIs("data")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -175,11 +174,7 @@ bool nsContentSecurityManager::AllowInsecureRedirectToDataURI(
|
||||
}
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
nsresult rv = NS_GetFinalChannelURI(aNewChannel, getter_AddRefs(newURI));
|
||||
if (NS_FAILED(rv) || !newURI) {
|
||||
return true;
|
||||
}
|
||||
bool isDataURI = newURI->SchemeIs("data");
|
||||
if (!isDataURI) {
|
||||
if (NS_FAILED(rv) || !newURI || !newURI->SchemeIs("data")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1007,15 +1002,15 @@ nsresult nsContentSecurityManager::CheckAllowLoadInSystemPrivilegedContext(
|
||||
|
||||
if (contentPolicyType == ExtContentPolicy::TYPE_SUBDOCUMENT) {
|
||||
if (StaticPrefs::security_disallow_privileged_https_subdocuments_loads() &&
|
||||
(innerURI->SchemeIs("http") || innerURI->SchemeIs("https"))) {
|
||||
net::SchemeIsHttpOrHttps(innerURI)) {
|
||||
MOZ_ASSERT(
|
||||
false,
|
||||
"Disallowing SystemPrincipal load of subdocuments on HTTP(S).");
|
||||
aChannel->Cancel(NS_ERROR_CONTENT_BLOCKED);
|
||||
return NS_ERROR_CONTENT_BLOCKED;
|
||||
}
|
||||
if ((StaticPrefs::security_disallow_privileged_data_subdocuments_loads()) &&
|
||||
(innerURI->SchemeIs("data"))) {
|
||||
if (StaticPrefs::security_disallow_privileged_data_subdocuments_loads() &&
|
||||
innerURI->SchemeIs("data")) {
|
||||
MOZ_ASSERT(
|
||||
false,
|
||||
"Disallowing SystemPrincipal load of subdocuments on data URL.");
|
||||
@@ -1024,8 +1019,8 @@ nsresult nsContentSecurityManager::CheckAllowLoadInSystemPrivilegedContext(
|
||||
}
|
||||
}
|
||||
if (contentPolicyType == ExtContentPolicy::TYPE_SCRIPT) {
|
||||
if ((StaticPrefs::security_disallow_privileged_https_script_loads()) &&
|
||||
(innerURI->SchemeIs("http") || innerURI->SchemeIs("https"))) {
|
||||
if (StaticPrefs::security_disallow_privileged_https_script_loads() &&
|
||||
net::SchemeIsHttpOrHttps(innerURI)) {
|
||||
MOZ_ASSERT(false,
|
||||
"Disallowing SystemPrincipal load of scripts on HTTP(S).");
|
||||
aChannel->Cancel(NS_ERROR_CONTENT_BLOCKED);
|
||||
@@ -1034,7 +1029,7 @@ nsresult nsContentSecurityManager::CheckAllowLoadInSystemPrivilegedContext(
|
||||
}
|
||||
if (contentPolicyType == ExtContentPolicy::TYPE_STYLESHEET) {
|
||||
if (StaticPrefs::security_disallow_privileged_https_stylesheet_loads() &&
|
||||
(innerURI->SchemeIs("http") || innerURI->SchemeIs("https"))) {
|
||||
net::SchemeIsHttpOrHttps(innerURI)) {
|
||||
MOZ_ASSERT(false,
|
||||
"Disallowing SystemPrincipal load of stylesheets on HTTP(S).");
|
||||
aChannel->Cancel(NS_ERROR_CONTENT_BLOCKED);
|
||||
@@ -1091,8 +1086,7 @@ nsresult nsContentSecurityManager::CheckAllowLoadInPrivilegedAboutContext(
|
||||
&isLocal);
|
||||
// We allow URLs that are URI_IS_LOCAL (but that includes `data`
|
||||
// and `blob` which are also undesirable.
|
||||
if ((isLocal) && (!innerURI->SchemeIs("data")) &&
|
||||
(!innerURI->SchemeIs("blob"))) {
|
||||
if (isLocal && !innerURI->SchemeIs("data") && !innerURI->SchemeIs("blob")) {
|
||||
return NS_OK;
|
||||
}
|
||||
MOZ_ASSERT(
|
||||
@@ -1759,10 +1753,8 @@ nsresult nsContentSecurityManager::CheckForIncoherentResultPrincipal(
|
||||
|
||||
if (nsScriptSecurityManager::IsHttpOrHttpsAndCrossOrigin(
|
||||
resultSiteOriginURI, channelSiteOriginURI) ||
|
||||
(!net::SchemeIsHTTP(resultSiteOriginURI) &&
|
||||
!net::SchemeIsHTTPS(resultSiteOriginURI) &&
|
||||
(net::SchemeIsHTTP(channelSiteOriginURI) ||
|
||||
net::SchemeIsHTTPS(channelSiteOriginURI)))) {
|
||||
(!net::SchemeIsHttpOrHttps(resultSiteOriginURI) &&
|
||||
net::SchemeIsHttpOrHttps(channelSiteOriginURI))) {
|
||||
return NS_ERROR_CONTENT_BLOCKED;
|
||||
}
|
||||
|
||||
|
||||
@@ -927,12 +927,12 @@ bool nsHTTPSOnlyUtils::IsHttpDowngrade(nsIURI* aFromURI, nsIURI* aToURI) {
|
||||
}
|
||||
|
||||
// 2. If the target URI is not http, then it's not a http downgrade
|
||||
if (!mozilla::net::SchemeIsHTTP(aToURI)) {
|
||||
if (!aToURI->SchemeIs("http")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 3. If the origin URI isn't https, then it's not a http downgrade either.
|
||||
if (!mozilla::net::SchemeIsHTTPS(aFromURI)) {
|
||||
if (!aFromURI->SchemeIs("https")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ void ServiceWorkerScopeAndScriptAreValid(const ClientInfo& aClientInfo,
|
||||
}
|
||||
|
||||
auto hasHTTPScheme = [](nsIURI* aURI) -> bool {
|
||||
return aURI->SchemeIs("http") || aURI->SchemeIs("https");
|
||||
return net::SchemeIsHttpOrHttps(aURI);
|
||||
};
|
||||
auto hasMozExtScheme = [](nsIURI* aURI) -> bool {
|
||||
return aURI->SchemeIs("moz-extension");
|
||||
|
||||
@@ -153,8 +153,6 @@ URLSearchParams* URL::SearchParams() {
|
||||
return mSearchParams;
|
||||
}
|
||||
|
||||
bool IsChromeURI(nsIURI* aURI) { return aURI->SchemeIs("chrome"); }
|
||||
|
||||
void URL::CreateSearchParamsIfNeeded() {
|
||||
if (!mSearchParams) {
|
||||
mSearchParams = new URLSearchParams(mParent, this);
|
||||
|
||||
@@ -135,8 +135,6 @@ class URL final : public URLSearchParamsObserver, public nsWrapperCache {
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
};
|
||||
|
||||
bool IsChromeURI(nsIURI* aURI);
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
||||
@@ -58,6 +58,5 @@ bool ImageBlocker::ShouldBlock(nsIURI* aContentLocation) {
|
||||
|
||||
// we only want to check http, https
|
||||
// for chrome:// and resources and others, no need to check.
|
||||
return aContentLocation->SchemeIs("http") ||
|
||||
aContentLocation->SchemeIs("https");
|
||||
return net::SchemeIsHttpOrHttps(aContentLocation);
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ nsHyphenator::nsHyphenator(nsIURI* aURI, bool aHyphenateCapitalized)
|
||||
// We get file:// URIs when running an unpackaged build; they could also
|
||||
// occur if we support adding hyphenation dictionaries by putting files in
|
||||
// a directory of the profile, for example.
|
||||
if (net::SchemeIsFile(aURI)) {
|
||||
if (aURI->SchemeIs("file")) {
|
||||
// Ask the Rust lib to mmap the file. In this case our mDictSize field
|
||||
// remains zero; mDict is not a pointer to the raw data but an opaque
|
||||
// reference to a Rust object, and can only be freed by passing it to
|
||||
|
||||
@@ -109,7 +109,7 @@ static bool IsNullOrHttp(nsIURI* uri) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return uri->SchemeIs("http") || uri->SchemeIs("https");
|
||||
return SchemeIsHttpOrHttps(uri);
|
||||
}
|
||||
|
||||
// Listener for the speculative DNS requests we'll fire off, which just ignores
|
||||
|
||||
@@ -2114,7 +2114,7 @@ nsresult nsIOService::SpeculativeConnectInternal(
|
||||
nsIInterfaceRequestor* aCallbacks, bool aAnonymous) {
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
if (!aURI->SchemeIs("http") && !aURI->SchemeIs("https")) {
|
||||
if (!SchemeIsHttpOrHttps(aURI)) {
|
||||
// We don't speculatively connect to non-HTTP[S] URIs.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -3366,59 +3366,9 @@ bool ChannelIsPost(nsIChannel* aChannel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SchemeIsHTTP(nsIURI* aURI) {
|
||||
bool SchemeIsHttpOrHttps(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("http");
|
||||
}
|
||||
|
||||
bool SchemeIsHTTPS(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("https");
|
||||
}
|
||||
|
||||
bool SchemeIsJavascript(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("javascript");
|
||||
}
|
||||
|
||||
bool SchemeIsChrome(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("chrome");
|
||||
}
|
||||
|
||||
bool SchemeIsAbout(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("about");
|
||||
}
|
||||
|
||||
bool SchemeIsBlob(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("blob");
|
||||
}
|
||||
|
||||
bool SchemeIsFile(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("file");
|
||||
}
|
||||
|
||||
bool SchemeIsData(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("data");
|
||||
}
|
||||
|
||||
bool SchemeIsViewSource(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("view-source");
|
||||
}
|
||||
|
||||
bool SchemeIsResource(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("resource");
|
||||
}
|
||||
|
||||
bool SchemeIsFTP(nsIURI* aURI) {
|
||||
MOZ_ASSERT(aURI);
|
||||
return aURI->SchemeIs("ftp");
|
||||
return aURI->SchemeIs("http") || aURI->SchemeIs("https");
|
||||
}
|
||||
|
||||
bool SchemeIsSpecial(const nsACString& aScheme) {
|
||||
|
||||
@@ -1091,21 +1091,9 @@ nsresult GetParameterHTTP(const nsACString& aHeaderVal, const char* aParamName,
|
||||
bool ChannelIsPost(nsIChannel* aChannel);
|
||||
|
||||
/**
|
||||
* Convenience functions for verifying nsIURI schemes. These functions simply
|
||||
* wrap aURI->SchemeIs(), but specify the protocol as part of the function name.
|
||||
* Convenience function for verifying nsIURI scheme is either HTTP or HTTPS.
|
||||
*/
|
||||
|
||||
bool SchemeIsHTTP(nsIURI* aURI);
|
||||
bool SchemeIsHTTPS(nsIURI* aURI);
|
||||
bool SchemeIsJavascript(nsIURI* aURI);
|
||||
bool SchemeIsChrome(nsIURI* aURI);
|
||||
bool SchemeIsAbout(nsIURI* aURI);
|
||||
bool SchemeIsBlob(nsIURI* aURI);
|
||||
bool SchemeIsFile(nsIURI* aURI);
|
||||
bool SchemeIsData(nsIURI* aURI);
|
||||
bool SchemeIsViewSource(nsIURI* aURI);
|
||||
bool SchemeIsResource(nsIURI* aURI);
|
||||
bool SchemeIsFTP(nsIURI* aURI);
|
||||
bool SchemeIsHttpOrHttps(nsIURI* aURI);
|
||||
|
||||
// Helper functions for SetProtocol methods to follow
|
||||
// step 2.1 in https://url.spec.whatwg.org/#scheme-state
|
||||
|
||||
@@ -156,7 +156,7 @@ nsDocShell* DocumentChannel::GetDocShell() {
|
||||
}
|
||||
|
||||
static bool URIUsesDocChannel(nsIURI* aURI) {
|
||||
if (SchemeIsJavascript(aURI)) {
|
||||
if (aURI->SchemeIs("javascript")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,15 +119,15 @@ static auto SecurityFlagsForLoadInfo(nsDocShellLoadState* aLoadState)
|
||||
}
|
||||
|
||||
if (aLoadState->PrincipalToInherit()) {
|
||||
nsIURI* uri = aLoadState->URI();
|
||||
bool isSrcdoc = aLoadState->HasInternalLoadFlags(
|
||||
nsDocShell::INTERNAL_LOAD_FLAGS_IS_SRCDOC);
|
||||
bool inheritAttrs = nsContentUtils::ChannelShouldInheritPrincipal(
|
||||
aLoadState->PrincipalToInherit(), aLoadState->URI(),
|
||||
aLoadState->PrincipalToInherit(), uri,
|
||||
true, // aInheritForAboutBlank
|
||||
isSrcdoc);
|
||||
|
||||
bool isData = SchemeIsData(aLoadState->URI());
|
||||
if (inheritAttrs && !isData) {
|
||||
if (inheritAttrs && !uri->SchemeIs("data")) {
|
||||
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
|
||||
}
|
||||
}
|
||||
@@ -691,7 +691,7 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
|
||||
mLoadIdentifier = aLoadState->GetLoadIdentifier();
|
||||
// See description of mFileName in nsDocShellLoadState.h
|
||||
mIsDownload = !aLoadState->FileName().IsVoid();
|
||||
mIsLoadingJSURI = net::SchemeIsJavascript(aLoadState->URI());
|
||||
mIsLoadingJSURI = aLoadState->URI()->SchemeIs("javascript");
|
||||
mHTTPSFirstDowngradeData = aLoadState->GetHttpsFirstDowngradeData().forget();
|
||||
|
||||
// Check for infinite recursive object or iframe loads
|
||||
|
||||
@@ -4473,7 +4473,7 @@ already_AddRefed<nsILoadInfo> HttpBaseChannel::CloneLoadInfoForRedirect(
|
||||
// the "external" flag, as loads that now go to other apps should be
|
||||
// allowed to go ahead and not trip infinite-loop protection
|
||||
// (see bug 1717314 for context).
|
||||
if (!aNewURI->SchemeIs("http") && !aNewURI->SchemeIs("https")) {
|
||||
if (!net::SchemeIsHttpOrHttps(aNewURI)) {
|
||||
newLoadInfo->SetLoadTriggeredFromExternal(false);
|
||||
}
|
||||
newLoadInfo->ResetSandboxedNullPrincipalID();
|
||||
|
||||
@@ -3149,10 +3149,8 @@ void nsHttpChannel::UpdateCacheDisposition(bool aSuccessfulReval,
|
||||
nsresult nsHttpChannel::ContinueProcessResponse4(nsresult rv) {
|
||||
bool doNotRender = DoNotRender3xxBody(rv);
|
||||
|
||||
if (rv == NS_ERROR_DOM_BAD_URI && mRedirectURI) {
|
||||
bool isHTTP =
|
||||
mRedirectURI->SchemeIs("http") || mRedirectURI->SchemeIs("https");
|
||||
if (!isHTTP) {
|
||||
if (rv == NS_ERROR_DOM_BAD_URI && mRedirectURI &&
|
||||
!net::SchemeIsHttpOrHttps(mRedirectURI)) {
|
||||
// This was a blocked attempt to redirect and subvert the system by
|
||||
// redirecting to another protocol (perhaps javascript:)
|
||||
// In that case we want to throw an error instead of displaying the
|
||||
@@ -3161,7 +3159,6 @@ nsresult nsHttpChannel::ContinueProcessResponse4(nsresult rv) {
|
||||
doNotRender = true;
|
||||
rv = NS_ERROR_CORRUPTED_CONTENT;
|
||||
}
|
||||
}
|
||||
|
||||
if (doNotRender) {
|
||||
Cancel(rv);
|
||||
|
||||
@@ -2042,7 +2042,7 @@ nsHttpHandler::NewChannel(nsIURI* uri, nsILoadInfo* aLoadInfo,
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
|
||||
// Verify that we have been given a valid scheme
|
||||
if (!uri->SchemeIs("http") && !uri->SchemeIs("https")) {
|
||||
if (!net::SchemeIsHttpOrHttps(uri)) {
|
||||
NS_WARNING("Invalid URI scheme");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
@@ -2866,8 +2866,7 @@ void nsHttpHandler::MaybeAddAltSvcForTesting(
|
||||
return;
|
||||
}
|
||||
|
||||
bool isHttps = false;
|
||||
if (NS_FAILED(aUri->SchemeIs("https", &isHttps)) || !isHttps) {
|
||||
if (!aUri->SchemeIs("https")) {
|
||||
// Only set for HTTPS.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,10 +175,8 @@ nsresult nsViewSourceChannel::UpdateLoadInfoResultPrincipalURI() {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
bool alreadyViewSource;
|
||||
if (NS_SUCCEEDED(channelResultPrincipalURI->SchemeIs("view-source",
|
||||
&alreadyViewSource)) &&
|
||||
alreadyViewSource) {
|
||||
if (channelResultPrincipalURI->SchemeIs("view-source")) {
|
||||
// already view-source
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,15 +78,9 @@ void nsHtml5DocumentBuilder::SetDocumentMode(nsHtml5DocumentMode m) {
|
||||
|
||||
if (errMsgId && !mDocument->IsLoadedAsData()) {
|
||||
nsCOMPtr<nsIURI> docURI = mDocument->GetDocumentURI();
|
||||
bool isData = false;
|
||||
docURI->SchemeIs("data", &isData);
|
||||
bool isHttp = false;
|
||||
docURI->SchemeIs("http", &isHttp);
|
||||
bool isHttps = false;
|
||||
docURI->SchemeIs("https", &isHttps);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal = mDocument->GetPrincipal();
|
||||
if (principal->GetIsNullPrincipal() && !isData && !isHttp && !isHttps) {
|
||||
if (principal->GetIsNullPrincipal() && !docURI->SchemeIs("data") &&
|
||||
!mozilla::net::SchemeIsHttpOrHttps(docURI)) {
|
||||
// Don't normally warn for null principals. It may well be internal
|
||||
// documents for which the warning is not applicable.
|
||||
return;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "nsCharsetSource.h"
|
||||
#include "nsParser.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/URL.h"
|
||||
#include "mozilla/dom/PrototypeDocumentContentSink.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
@@ -64,7 +63,7 @@ PrototypeDocumentParser::Parse(nsIURI* aURL) {
|
||||
// Look in the chrome cache: we've got this puppy loaded
|
||||
// already.
|
||||
nsXULPrototypeDocument* proto =
|
||||
IsChromeURI(mDocumentURI)
|
||||
mDocumentURI->SchemeIs("chrome")
|
||||
? nsXULPrototypeCache::GetInstance()->GetPrototype(mDocumentURI)
|
||||
: nullptr;
|
||||
|
||||
@@ -183,7 +182,7 @@ nsresult PrototypeDocumentParser::PrepareToLoadPrototype(
|
||||
|
||||
// Store the new prototype right away so if there are multiple requests
|
||||
// for the same document they all get the same prototype.
|
||||
if (IsChromeURI(mDocumentURI) &&
|
||||
if (mDocumentURI->SchemeIs("chrome") &&
|
||||
nsXULPrototypeCache::GetInstance()->IsEnabled()) {
|
||||
nsXULPrototypeCache::GetInstance()->PutPrototype(mCurrentPrototype);
|
||||
}
|
||||
|
||||
@@ -452,7 +452,7 @@ nsresult BounceTrackingState::OnDocumentStartRequest(nsIChannel* aChannel) {
|
||||
rv = aChannel->GetURI(getter_AddRefs(channelURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (channelURI->SchemeIs("http") || channelURI->SchemeIs("https")) {
|
||||
if (mozilla::net::SchemeIsHttpOrHttps(channelURI)) {
|
||||
nsCOMPtr<nsIEffectiveTLDService> tldService =
|
||||
do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -1675,8 +1675,7 @@ void SessionStoreUtils::RestoreDocShellState(
|
||||
if (aDocShell) {
|
||||
nsCOMPtr<nsIURI> currentUri;
|
||||
nsDocShell::Cast(aDocShell)->GetCurrentURI(getter_AddRefs(currentUri));
|
||||
if (aState.URI() &&
|
||||
(!currentUri || mozilla::net::SchemeIsAbout(currentUri))) {
|
||||
if (aState.URI() && (!currentUri || currentUri->SchemeIs("about"))) {
|
||||
aDocShell->SetCurrentURIForSessionStore(aState.URI());
|
||||
}
|
||||
RestoreDocShellCapabilities(aDocShell, aState.docShellCaps());
|
||||
|
||||
@@ -1765,7 +1765,7 @@ nsXULAppInfo::GetServerURL(nsIURL** aServerURL) {
|
||||
NS_IMETHODIMP
|
||||
nsXULAppInfo::SetServerURL(nsIURL* aServerURL) {
|
||||
// Only allow https or http URLs
|
||||
if (!aServerURL->SchemeIs("http") && !aServerURL->SchemeIs("https")) {
|
||||
if (!net::SchemeIsHttpOrHttps(aServerURL)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
||||
@@ -3277,7 +3277,7 @@ bool nsExternalHelperAppService::GetFileNameFromChannel(nsIChannel* aChannel,
|
||||
nsAutoCString query;
|
||||
|
||||
// We only care about the query for HTTP and HTTPS URLs
|
||||
if (url->SchemeIs("http") || url->SchemeIs("https")) {
|
||||
if (net::SchemeIsHttpOrHttps(url)) {
|
||||
url->GetQuery(query);
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ nsPrefetchNode::AsyncOnChannelRedirect(
|
||||
nsresult rv = aNewChannel->GetURI(getter_AddRefs(newURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!newURI->SchemeIs("http") && !newURI->SchemeIs("https")) {
|
||||
if (!net::SchemeIsHttpOrHttps(newURI)) {
|
||||
LOG(("rejected: URL is not of type http/https\n"));
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
@@ -550,7 +550,7 @@ nsresult nsPrefetchService::CheckURIScheme(nsIURI* aURI,
|
||||
// for now, we'll only prefetch http and https links since we know that's
|
||||
// the most common case.
|
||||
//
|
||||
if (!aURI->SchemeIs("http") && !aURI->SchemeIs("https")) {
|
||||
if (!net::SchemeIsHttpOrHttps(aURI)) {
|
||||
LOG(("rejected: URL is not of type http/https\n"));
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
@@ -563,7 +563,7 @@ nsresult nsPrefetchService::CheckURIScheme(nsIURI* aURI,
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
if (!referrer->SchemeIs("http") && !referrer->SchemeIs("https")) {
|
||||
if (!net::SchemeIsHttpOrHttps(referrer)) {
|
||||
LOG(("rejected: referrer URL is neither http nor https\n"));
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
@@ -2346,7 +2346,7 @@ RefPtr<MozPromise<bool, bool, false>> nsWindow::OnLoadRequest(
|
||||
nsAutoCString spec, triggeringSpec;
|
||||
if (aUri) {
|
||||
aUri->GetDisplaySpec(spec);
|
||||
if (aIsTopLevel && mozilla::net::SchemeIsData(aUri) &&
|
||||
if (aIsTopLevel && aUri->SchemeIs("data") &&
|
||||
spec.Length() > MAX_TOPLEVEL_DATA_URI_LEN) {
|
||||
return MozPromise<bool, bool, false>::CreateAndResolve(false, __func__);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user