mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1558915 - Use infallible nsIURI::SchemeIs in toolkit/ r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D40323 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
f115dd9113
commit
c16799f4af
@ -220,10 +220,7 @@ int32_t CookiesBehavior(nsILoadInfo* aLoadInfo,
|
|||||||
|
|
||||||
// WebExtensions 3rd party URI always get BEHAVIOR_ACCEPT as cookieBehavior,
|
// WebExtensions 3rd party URI always get BEHAVIOR_ACCEPT as cookieBehavior,
|
||||||
// this is semantically equivalent to the principal having a AddonPolicy().
|
// this is semantically equivalent to the principal having a AddonPolicy().
|
||||||
bool is3rdPartyMozExt = false;
|
if (a3rdPartyURI->SchemeIs("moz-extension")) {
|
||||||
if (NS_SUCCEEDED(
|
|
||||||
a3rdPartyURI->SchemeIs("moz-extension", &is3rdPartyMozExt)) &&
|
|
||||||
is3rdPartyMozExt) {
|
|
||||||
return nsICookieService::BEHAVIOR_ACCEPT;
|
return nsICookieService::BEHAVIOR_ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,12 +138,8 @@ static StorageAccess InternalStorageAllowedCheck(
|
|||||||
if (!uri) {
|
if (!uri) {
|
||||||
Unused << aPrincipal->GetURI(getter_AddRefs(uri));
|
Unused << aPrincipal->GetURI(getter_AddRefs(uri));
|
||||||
}
|
}
|
||||||
if (uri) {
|
if (uri && uri->SchemeIs("about")) {
|
||||||
bool isAbout = false;
|
return access;
|
||||||
MOZ_ALWAYS_SUCCEEDS(uri->SchemeIs("about", &isAbout));
|
|
||||||
if (isAbout) {
|
|
||||||
return access;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StorageDisabledByAntiTracking(aWindow, aChannel, aPrincipal, aURI,
|
if (!StorageDisabledByAntiTracking(aWindow, aChannel, aPrincipal, aURI,
|
||||||
|
@ -1919,10 +1919,7 @@ nsNavBookmarks::OnPageChanged(nsIURI* aURI, uint32_t aChangedAttribute,
|
|||||||
changeData.bookmark.type = TYPE_BOOKMARK;
|
changeData.bookmark.type = TYPE_BOOKMARK;
|
||||||
|
|
||||||
// Favicons may be set to either pure URIs or to folder URIs
|
// Favicons may be set to either pure URIs or to folder URIs
|
||||||
bool isPlaceURI;
|
if (aURI->SchemeIs("place")) {
|
||||||
rv = aURI->SchemeIs("place", &isPlaceURI);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
if (isPlaceURI) {
|
|
||||||
nsNavHistory* history = nsNavHistory::GetHistoryService();
|
nsNavHistory* history = nsNavHistory::GetHistoryService();
|
||||||
NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
|
@ -178,8 +178,7 @@ nsresult nsUrlClassifierStreamUpdater::FetchUpdate(
|
|||||||
// purposes.
|
// purposes.
|
||||||
// This is only used for testing and should be deleted.
|
// This is only used for testing and should be deleted.
|
||||||
bool match;
|
bool match;
|
||||||
if ((NS_SUCCEEDED(aUpdateUrl->SchemeIs("file", &match)) && match) ||
|
if (aUpdateUrl->SchemeIs("file") || aUpdateUrl->SchemeIs("data")) {
|
||||||
(NS_SUCCEEDED(aUpdateUrl->SchemeIs("data", &match)) && match)) {
|
|
||||||
mChannel->SetContentType(
|
mChannel->SetContentType(
|
||||||
NS_LITERAL_CSTRING("application/vnd.google.safebrowsing-update"));
|
NS_LITERAL_CSTRING("application/vnd.google.safebrowsing-update"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -617,7 +617,7 @@ nsresult nsWindowWatcher::OpenWindowInternal(
|
|||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
uriToLoad->SchemeIs("chrome", &uriToLoadIsChrome);
|
uriToLoadIsChrome = uriToLoad->SchemeIs("chrome");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nameSpecified = false;
|
bool nameSpecified = false;
|
||||||
|
@ -112,10 +112,8 @@ AddonContentPolicy::ShouldLoad(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
|
|||||||
// Only apply this policy to requests from documents loaded from
|
// Only apply this policy to requests from documents loaded from
|
||||||
// moz-extension URLs, or to resources being loaded from moz-extension URLs.
|
// moz-extension URLs, or to resources being loaded from moz-extension URLs.
|
||||||
bool equals;
|
bool equals;
|
||||||
if (!((NS_SUCCEEDED(aContentLocation->SchemeIs("moz-extension", &equals)) &&
|
if (!(aContentLocation->SchemeIs("moz-extension") ||
|
||||||
equals) ||
|
requestOrigin->SchemeIs("moz-extension"))) {
|
||||||
(NS_SUCCEEDED(requestOrigin->SchemeIs("moz-extension", &equals)) &&
|
|
||||||
equals))) {
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,9 +55,7 @@ bool AddonManagerWebAPI::IsValidSite(nsIURI* uri) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSecure;
|
if (!uri->SchemeIs("https")) {
|
||||||
nsresult rv = uri->SchemeIs("https", &isSecure);
|
|
||||||
if (NS_FAILED(rv) || !isSecure) {
|
|
||||||
if (!(xpc::IsInAutomation() &&
|
if (!(xpc::IsInAutomation() &&
|
||||||
Preferences::GetBool("extensions.webapi.testing.http", false))) {
|
Preferences::GetBool("extensions.webapi.testing.http", false))) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -175,10 +175,7 @@ static nsresult GetProxyFromEnvironment(const nsACString& aScheme,
|
|||||||
|
|
||||||
// Is there a way to specify "socks://" or something in these environment
|
// Is there a way to specify "socks://" or something in these environment
|
||||||
// variables? I can't find any documentation.
|
// variables? I can't find any documentation.
|
||||||
bool isHTTP;
|
if (!proxyURI->SchemeIs("http")) return NS_ERROR_UNKNOWN_PROTOCOL;
|
||||||
rv = proxyURI->SchemeIs("http", &isHTTP);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
if (!isHTTP) return NS_ERROR_UNKNOWN_PROTOCOL;
|
|
||||||
|
|
||||||
nsAutoCString proxyHost;
|
nsAutoCString proxyHost;
|
||||||
rv = proxyURI->GetHost(proxyHost);
|
rv = proxyURI->GetHost(proxyHost);
|
||||||
|
@ -1001,16 +1001,11 @@ nsXULAppInfo::GetServerURL(nsIURL** aServerURL) {
|
|||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsXULAppInfo::SetServerURL(nsIURL* aServerURL) {
|
nsXULAppInfo::SetServerURL(nsIURL* aServerURL) {
|
||||||
bool schemeOk;
|
// Only allow https or http URLs
|
||||||
// only allow https or http URLs
|
if (!aServerURL->SchemeIs("http") && !aServerURL->SchemeIs("https")) {
|
||||||
nsresult rv = aServerURL->SchemeIs("https", &schemeOk);
|
return NS_ERROR_INVALID_ARG;
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
if (!schemeOk) {
|
|
||||||
rv = aServerURL->SchemeIs("http", &schemeOk);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
if (!schemeOk) return NS_ERROR_INVALID_ARG;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoCString spec;
|
nsAutoCString spec;
|
||||||
rv = aServerURL->GetSpec(spec);
|
rv = aServerURL->GetSpec(spec);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
Loading…
Reference in New Issue
Block a user