mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-23 07:37:29 +09:00
Issue #2578 - Part 2: Implement preference for disabling CORS preflight requests if CORS is disabled
This commit is contained in:
parent
09b3c7a2d8
commit
2d60c54926
1 changed files with 10 additions and 0 deletions
|
|
@ -53,6 +53,7 @@ using namespace mozilla;
|
||||||
|
|
||||||
static bool gDisableCORS = false;
|
static bool gDisableCORS = false;
|
||||||
static bool gDisableCORSPrivateData = false;
|
static bool gDisableCORSPrivateData = false;
|
||||||
|
static bool gBypassCORSPreflightRequest = false;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
LogBlockedRequest(nsIRequest* aRequest,
|
LogBlockedRequest(nsIRequest* aRequest,
|
||||||
|
|
@ -414,6 +415,8 @@ nsCORSListenerProxy::Startup()
|
||||||
"content.cors.disable");
|
"content.cors.disable");
|
||||||
Preferences::AddBoolVarCache(&gDisableCORSPrivateData,
|
Preferences::AddBoolVarCache(&gDisableCORSPrivateData,
|
||||||
"content.cors.no_private_data");
|
"content.cors.no_private_data");
|
||||||
|
Preferences::AddBoolVarCache(&gBypassCORSPreflightRequest,
|
||||||
|
"content.cors.bypass_preflight_request");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
@ -543,6 +546,9 @@ nsCORSListenerProxy::CheckRequestApproved(nsIRequest* aRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gDisableCORS) {
|
if (gDisableCORS) {
|
||||||
|
if (gBypassCORSPreflightRequest) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
LogBlockedRequest(aRequest, "CORSDisabled", nullptr);
|
LogBlockedRequest(aRequest, "CORSDisabled", nullptr);
|
||||||
return NS_ERROR_DOM_BAD_URI;
|
return NS_ERROR_DOM_BAD_URI;
|
||||||
}
|
}
|
||||||
|
|
@ -1413,6 +1419,10 @@ nsCORSListenerProxy::StartCORSPreflight(nsIChannel* aRequestChannel,
|
||||||
*aPreflightChannel = nullptr;
|
*aPreflightChannel = nullptr;
|
||||||
|
|
||||||
if (gDisableCORS) {
|
if (gDisableCORS) {
|
||||||
|
if (gBypassCORSPreflightRequest) {
|
||||||
|
aCallback->OnPreflightSucceeded();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
LogBlockedRequest(aRequestChannel, "CORSDisabled", nullptr);
|
LogBlockedRequest(aRequestChannel, "CORSDisabled", nullptr);
|
||||||
return NS_ERROR_DOM_BAD_URI;
|
return NS_ERROR_DOM_BAD_URI;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue