mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-30 12:27:29 +09:00
moebius#226: Consider blocking top level window data: URIs (part 2/2 without tests)
https://github.com/MoonchildProductions/moebius/pull/226
This commit is contained in:
parent
712d19e1b7
commit
73f89fe562
16 changed files with 194 additions and 66 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
#include "nsIHttpChannel.h"
|
#include "nsIHttpChannel.h"
|
||||||
#include "nsIScriptSecurityManager.h"
|
#include "nsIScriptSecurityManager.h"
|
||||||
#include "nsError.h"
|
#include "nsError.h"
|
||||||
|
#include "nsContentSecurityManager.h"
|
||||||
#include "nsCharSeparatedTokenizer.h"
|
#include "nsCharSeparatedTokenizer.h"
|
||||||
#include "nsIConsoleService.h"
|
#include "nsIConsoleService.h"
|
||||||
#include "nsIScriptError.h"
|
#include "nsIScriptError.h"
|
||||||
|
|
@ -93,6 +94,14 @@ nsDSURIContentListener::DoContent(const nsACString& aContentType,
|
||||||
|
|
||||||
if (aOpenedChannel) {
|
if (aOpenedChannel) {
|
||||||
aOpenedChannel->GetLoadFlags(&loadFlags);
|
aOpenedChannel->GetLoadFlags(&loadFlags);
|
||||||
|
|
||||||
|
// block top-level data URI navigations if triggered by the web
|
||||||
|
if (!nsContentSecurityManager::AllowTopLevelNavigationToDataURI(aOpenedChannel)) {
|
||||||
|
// logging to console happens within AllowTopLevelNavigationToDataURI
|
||||||
|
aRequest->Cancel(NS_ERROR_DOM_BAD_URI);
|
||||||
|
*aAbortProcess = true;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
||||||
|
|
|
||||||
|
|
@ -9885,15 +9885,6 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
||||||
contentType = nsIContentPolicy::TYPE_DOCUMENT;
|
contentType = nsIContentPolicy::TYPE_DOCUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
|
|
||||||
aURI,
|
|
||||||
contentType,
|
|
||||||
aTriggeringPrincipal,
|
|
||||||
(aLoadType == LOAD_NORMAL_EXTERNAL))) {
|
|
||||||
// logging to console happens within AllowTopLevelNavigationToDataURI
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there's no targetDocShell, that means we are about to create a new window,
|
// If there's no targetDocShell, that means we are about to create a new window,
|
||||||
// perform a content policy check before creating the window.
|
// perform a content policy check before creating the window.
|
||||||
if (!targetDocShell) {
|
if (!targetDocShell) {
|
||||||
|
|
@ -10962,6 +10953,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
||||||
if (aPrincipalToInherit) {
|
if (aPrincipalToInherit) {
|
||||||
loadInfo->SetPrincipalToInherit(aPrincipalToInherit);
|
loadInfo->SetPrincipalToInherit(aPrincipalToInherit);
|
||||||
}
|
}
|
||||||
|
loadInfo->SetLoadTriggeredFromExternal(aLoadFromExternal);
|
||||||
|
|
||||||
// We have to do this in case our OriginAttributes are different from the
|
// We have to do this in case our OriginAttributes are different from the
|
||||||
// OriginAttributes of the parent document. Or in case there isn't a
|
// OriginAttributes of the parent document. Or in case there isn't a
|
||||||
|
|
|
||||||
|
|
@ -10,20 +10,16 @@
|
||||||
#include "nsIStreamListener.h"
|
#include "nsIStreamListener.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsMixedContentBlocker.h"
|
#include "nsMixedContentBlocker.h"
|
||||||
#include "nsNullPrincipal.h"
|
|
||||||
|
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
|
#include "mozilla/dom/TabChild.h"
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsContentSecurityManager,
|
NS_IMPL_ISUPPORTS(nsContentSecurityManager,
|
||||||
nsIContentSecurityManager,
|
nsIContentSecurityManager,
|
||||||
nsIChannelEventSink)
|
nsIChannelEventSink)
|
||||||
|
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
|
nsContentSecurityManager::AllowTopLevelNavigationToDataURI(nsIChannel* aChannel)
|
||||||
nsIURI* aURI,
|
|
||||||
nsContentPolicyType aContentPolicyType,
|
|
||||||
nsIPrincipal* aTriggeringPrincipal,
|
|
||||||
bool aLoadFromExternal)
|
|
||||||
{
|
{
|
||||||
// Let's block all toplevel document navigations to a data: URI.
|
// Let's block all toplevel document navigations to a data: URI.
|
||||||
// In all cases where the toplevel document is navigated to a
|
// In all cases where the toplevel document is navigated to a
|
||||||
|
|
@ -36,17 +32,24 @@ nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
|
||||||
if (!mozilla::net::nsIOService::BlockToplevelDataUriNavigations()) {
|
if (!mozilla::net::nsIOService::BlockToplevelDataUriNavigations()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (aContentPolicyType != nsIContentPolicy::TYPE_DOCUMENT) {
|
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||||
|
if (!loadInfo) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (loadInfo->GetExternalContentPolicyType() != nsIContentPolicy::TYPE_DOCUMENT) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
nsCOMPtr<nsIURI> uri;
|
||||||
|
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
|
||||||
|
NS_ENSURE_SUCCESS(rv, true);
|
||||||
bool isDataURI =
|
bool isDataURI =
|
||||||
(NS_SUCCEEDED(aURI->SchemeIs("data", &isDataURI)) && isDataURI);
|
(NS_SUCCEEDED(uri->SchemeIs("data", &isDataURI)) && isDataURI);
|
||||||
if (!isDataURI) {
|
if (!isDataURI) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Whitelist data: images as long as they are not SVGs
|
// Whitelist data: images as long as they are not SVGs
|
||||||
nsAutoCString filePath;
|
nsAutoCString filePath;
|
||||||
aURI->GetFilePath(filePath);
|
uri->GetFilePath(filePath);
|
||||||
if (StringBeginsWith(filePath, NS_LITERAL_CSTRING("image/")) &&
|
if (StringBeginsWith(filePath, NS_LITERAL_CSTRING("image/")) &&
|
||||||
!StringBeginsWith(filePath, NS_LITERAL_CSTRING("image/svg+xml"))) {
|
!StringBeginsWith(filePath, NS_LITERAL_CSTRING("image/svg+xml"))) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -56,22 +59,29 @@ nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
|
||||||
StringBeginsWith(filePath, NS_LITERAL_CSTRING("application/json"))) {
|
StringBeginsWith(filePath, NS_LITERAL_CSTRING("application/json"))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!aLoadFromExternal &&
|
// Redirecting to a toplevel data: URI is not allowed, hence we make
|
||||||
nsContentUtils::IsSystemPrincipal(aTriggeringPrincipal)) {
|
// sure the RedirectChain is empty.
|
||||||
|
if (!loadInfo->GetLoadTriggeredFromExternal() &&
|
||||||
|
nsContentUtils::IsSystemPrincipal(loadInfo->TriggeringPrincipal()) &&
|
||||||
|
loadInfo->RedirectChain().IsEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
nsAutoCString dataSpec;
|
nsAutoCString dataSpec;
|
||||||
aURI->GetSpec(dataSpec);
|
uri->GetSpec(dataSpec);
|
||||||
if (dataSpec.Length() > 50) {
|
if (dataSpec.Length() > 50) {
|
||||||
dataSpec.Truncate(50);
|
dataSpec.Truncate(50);
|
||||||
dataSpec.AppendLiteral("...");
|
dataSpec.AppendLiteral("...");
|
||||||
}
|
}
|
||||||
|
nsCOMPtr<nsITabChild> tabChild = do_QueryInterface(loadInfo->ContextForTopLevelLoad());
|
||||||
|
nsCOMPtr<nsIDocument> doc;
|
||||||
|
if (tabChild) {
|
||||||
|
doc = static_cast<mozilla::dom::TabChild*>(tabChild.get())->GetDocument();
|
||||||
|
}
|
||||||
NS_ConvertUTF8toUTF16 specUTF16(NS_UnescapeURL(dataSpec));
|
NS_ConvertUTF8toUTF16 specUTF16(NS_UnescapeURL(dataSpec));
|
||||||
const char16_t* params[] = { specUTF16.get() };
|
const char16_t* params[] = { specUTF16.get() };
|
||||||
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
||||||
NS_LITERAL_CSTRING("DATA_URI_BLOCKED"),
|
NS_LITERAL_CSTRING("DATA_URI_BLOCKED"),
|
||||||
// no doc available, log to browser console
|
doc,
|
||||||
nullptr,
|
|
||||||
nsContentUtils::eSECURITY_PROPERTIES,
|
nsContentUtils::eSECURITY_PROPERTIES,
|
||||||
"BlockTopLevelDataURINavigation",
|
"BlockTopLevelDataURINavigation",
|
||||||
params, ArrayLength(params));
|
params, ArrayLength(params));
|
||||||
|
|
@ -541,27 +551,6 @@ nsContentSecurityManager::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirecting to a toplevel data: URI is not allowed, hence we pass
|
|
||||||
// a NullPrincipal as the TriggeringPrincipal to
|
|
||||||
// AllowTopLevelNavigationToDataURI() which definitely blocks any
|
|
||||||
// data: URI load.
|
|
||||||
nsCOMPtr<nsILoadInfo> newLoadInfo = aNewChannel->GetLoadInfo();
|
|
||||||
if (newLoadInfo) {
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
|
||||||
nsresult rv = NS_GetFinalChannelURI(aNewChannel, getter_AddRefs(uri));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
nsCOMPtr<nsIPrincipal> nullTriggeringPrincipal = nsNullPrincipal::Create();
|
|
||||||
if (!nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
|
|
||||||
uri,
|
|
||||||
newLoadInfo->GetExternalContentPolicyType(),
|
|
||||||
nullTriggeringPrincipal,
|
|
||||||
false)) {
|
|
||||||
// logging to console happens within AllowTopLevelNavigationToDataURI
|
|
||||||
aOldChannel->Cancel(NS_ERROR_DOM_BAD_URI);
|
|
||||||
return NS_ERROR_DOM_BAD_URI;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Also verify that the redirecting server is allowed to redirect to the
|
// Also verify that the redirecting server is allowed to redirect to the
|
||||||
// given URI
|
// given URI
|
||||||
nsCOMPtr<nsIPrincipal> oldPrincipal;
|
nsCOMPtr<nsIPrincipal> oldPrincipal;
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,7 @@ public:
|
||||||
static nsresult doContentSecurityCheck(nsIChannel* aChannel,
|
static nsresult doContentSecurityCheck(nsIChannel* aChannel,
|
||||||
nsCOMPtr<nsIStreamListener>& aInAndOutListener);
|
nsCOMPtr<nsIStreamListener>& aInAndOutListener);
|
||||||
|
|
||||||
static bool AllowTopLevelNavigationToDataURI(nsIURI* aURI,
|
static bool AllowTopLevelNavigationToDataURI(nsIChannel* aChannel);
|
||||||
nsContentPolicyType aContentPolicyType,
|
|
||||||
nsIPrincipal* aTriggeringPrincipal,
|
|
||||||
bool aLoadFromExternal);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static nsresult CheckChannel(nsIChannel* aChannel);
|
static nsresult CheckChannel(nsIChannel* aChannel);
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,9 @@
|
||||||
support-files =
|
support-files =
|
||||||
file_toplevel_data_navigations.sjs
|
file_toplevel_data_navigations.sjs
|
||||||
file_toplevel_data_meta_redirect.html
|
file_toplevel_data_meta_redirect.html
|
||||||
|
[browser_test_data_download.js]
|
||||||
|
support-files =
|
||||||
|
file_data_download.html
|
||||||
|
[browser_test_data_text_csv.js]
|
||||||
|
support-files =
|
||||||
|
file_data_text_csv.html
|
||||||
|
|
|
||||||
37
dom/security/test/general/browser_test_data_download.js
Normal file
37
dom/security/test/general/browser_test_data_download.js
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const kTestPath = getRootDirectory(gTestPath)
|
||||||
|
.replace("chrome://mochitests/content", "http://example.com")
|
||||||
|
const kTestURI = kTestPath + "file_data_download.html";
|
||||||
|
|
||||||
|
function addWindowListener(aURL, aCallback) {
|
||||||
|
Services.wm.addListener({
|
||||||
|
onOpenWindow(aXULWindow) {
|
||||||
|
info("window opened, waiting for focus");
|
||||||
|
Services.wm.removeListener(this);
|
||||||
|
var domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
|
.getInterface(Ci.nsIDOMWindow);
|
||||||
|
waitForFocus(function() {
|
||||||
|
is(domwindow.document.location.href, aURL, "should have seen the right window open");
|
||||||
|
aCallback(domwindow);
|
||||||
|
}, domwindow);
|
||||||
|
},
|
||||||
|
onCloseWindow(aXULWindow) { },
|
||||||
|
onWindowTitleChange(aXULWindow, aNewTitle) { }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
waitForExplicitFinish();
|
||||||
|
Services.prefs.setBoolPref("security.data_uri.block_toplevel_data_uri_navigations", true);
|
||||||
|
registerCleanupFunction(function() {
|
||||||
|
Services.prefs.clearUserPref("security.data_uri.block_toplevel_data_uri_navigations");
|
||||||
|
});
|
||||||
|
addWindowListener("chrome://mozapps/content/downloads/unknownContentType.xul", function(win) {
|
||||||
|
is(win.document.getElementById("location").value, "data-foo.html",
|
||||||
|
"file name of download should match");
|
||||||
|
win.close();
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
gBrowser.loadURI(kTestURI);
|
||||||
|
}
|
||||||
37
dom/security/test/general/browser_test_data_text_csv.js
Normal file
37
dom/security/test/general/browser_test_data_text_csv.js
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const kTestPath = getRootDirectory(gTestPath)
|
||||||
|
.replace("chrome://mochitests/content", "http://example.com")
|
||||||
|
const kTestURI = kTestPath + "file_data_text_csv.html";
|
||||||
|
|
||||||
|
function addWindowListener(aURL, aCallback) {
|
||||||
|
Services.wm.addListener({
|
||||||
|
onOpenWindow(aXULWindow) {
|
||||||
|
info("window opened, waiting for focus");
|
||||||
|
Services.wm.removeListener(this);
|
||||||
|
var domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
|
.getInterface(Ci.nsIDOMWindow);
|
||||||
|
waitForFocus(function() {
|
||||||
|
is(domwindow.document.location.href, aURL, "should have seen the right window open");
|
||||||
|
aCallback(domwindow);
|
||||||
|
}, domwindow);
|
||||||
|
},
|
||||||
|
onCloseWindow(aXULWindow) { },
|
||||||
|
onWindowTitleChange(aXULWindow, aNewTitle) { }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
waitForExplicitFinish();
|
||||||
|
Services.prefs.setBoolPref("security.data_uri.block_toplevel_data_uri_navigations", true);
|
||||||
|
registerCleanupFunction(function() {
|
||||||
|
Services.prefs.clearUserPref("security.data_uri.block_toplevel_data_uri_navigations");
|
||||||
|
});
|
||||||
|
addWindowListener("chrome://mozapps/content/downloads/unknownContentType.xul", function(win) {
|
||||||
|
is(win.document.getElementById("location").value, "text/csv;foo,bar,foobar",
|
||||||
|
"file name of download should match");
|
||||||
|
win.close();
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
gBrowser.loadURI(kTestURI);
|
||||||
|
}
|
||||||
14
dom/security/test/general/file_data_download.html
Normal file
14
dom/security/test/general/file_data_download.html
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Test download attribute for data: URI</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a href="data:text/html,<body>data download</body>" download="data-foo.html" id="testlink">download data</a>
|
||||||
|
<script>
|
||||||
|
// click the link to have the downoad panel appear
|
||||||
|
let testlink = document.getElementById("testlink");
|
||||||
|
testlink.click();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
14
dom/security/test/general/file_data_text_csv.html
Normal file
14
dom/security/test/general/file_data_text_csv.html
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Test open data:text/csv</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a href="data:text/csv;foo,bar,foobar" id="testlink">test text/csv</a>
|
||||||
|
<script>
|
||||||
|
// click the link to have the downoad panel appear
|
||||||
|
let testlink = document.getElementById("testlink");
|
||||||
|
testlink.click();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -34,15 +34,17 @@ function test_toplevel_data_image_svg() {
|
||||||
const DATA_SVG =
|
const DATA_SVG =
|
||||||
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBkPSJNOCwxMkwzLDcsNCw2bDQsNCw0LTQsMSwxWiIgZmlsbD0iIzZBNkE2QSIgLz4KPC9zdmc+Cg==";
|
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBkPSJNOCwxMkwzLDcsNCw2bDQsNCw0LTQsMSwxWiIgZmlsbD0iIzZBNkE2QSIgLz4KPC9zdmc+Cg==";
|
||||||
let win2 = window.open(DATA_SVG);
|
let win2 = window.open(DATA_SVG);
|
||||||
let wrappedWin2 = SpecialPowers.wrap(win2);
|
// Unfortunately we can't detect whether the window was closed using some event,
|
||||||
setTimeout(function () {
|
// hence we are constantly polling till we see that win == null.
|
||||||
isnot(wrappedWin2.document.documentElement.localName, "svg",
|
// Test times out on failure.
|
||||||
"Loading data:image/svg+xml should be blocked");
|
var win2Closed = setInterval(function() {
|
||||||
wrappedWin2.close();
|
if (win2 == null || win2.closed) {
|
||||||
|
clearInterval(win2Closed);
|
||||||
|
ok(true, "Loading data:image/svg+xml should be blocked");
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
// fire up the tests
|
// fire up the tests
|
||||||
test_toplevel_data_image();
|
test_toplevel_data_image();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,12 @@ function test1() {
|
||||||
// simple data: URI click navigation should be prevented
|
// simple data: URI click navigation should be prevented
|
||||||
let TEST_FILE = "file_block_toplevel_data_navigation.html";
|
let TEST_FILE = "file_block_toplevel_data_navigation.html";
|
||||||
let win1 = window.open(TEST_FILE);
|
let win1 = window.open(TEST_FILE);
|
||||||
var readyStateCheckInterval = setInterval(function() {
|
setTimeout(function () {
|
||||||
let state = win1.document.readyState;
|
ok(SpecialPowers.wrap(win1).document.body.innerHTML.indexOf("test1:") !== -1,
|
||||||
if (state === "interactive" || state === "complete") {
|
|
||||||
clearInterval(readyStateCheckInterval);
|
|
||||||
ok(win1.document.body.innerHTML.indexOf("test1:") !== -1,
|
|
||||||
"toplevel data: URI navigation through click() should be blocked");
|
"toplevel data: URI navigation through click() should be blocked");
|
||||||
win1.close();
|
win1.close();
|
||||||
test2();
|
test2();
|
||||||
}
|
}, 1000);
|
||||||
}, 200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test2() {
|
function test2() {
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,7 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
|
||||||
aLoadInfo->CorsUnsafeHeaders(),
|
aLoadInfo->CorsUnsafeHeaders(),
|
||||||
aLoadInfo->GetForcePreflight(),
|
aLoadInfo->GetForcePreflight(),
|
||||||
aLoadInfo->GetIsPreflight(),
|
aLoadInfo->GetIsPreflight(),
|
||||||
|
aLoadInfo->GetLoadTriggeredFromExternal(),
|
||||||
aLoadInfo->GetForceHSTSPriming(),
|
aLoadInfo->GetForceHSTSPriming(),
|
||||||
aLoadInfo->GetMixedContentWouldBlock());
|
aLoadInfo->GetMixedContentWouldBlock());
|
||||||
|
|
||||||
|
|
@ -370,6 +371,7 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
|
||||||
loadInfoArgs.corsUnsafeHeaders(),
|
loadInfoArgs.corsUnsafeHeaders(),
|
||||||
loadInfoArgs.forcePreflight(),
|
loadInfoArgs.forcePreflight(),
|
||||||
loadInfoArgs.isPreflight(),
|
loadInfoArgs.isPreflight(),
|
||||||
|
loadInfoArgs.loadTriggeredFromExternal(),
|
||||||
loadInfoArgs.forceHSTSPriming(),
|
loadInfoArgs.forceHSTSPriming(),
|
||||||
loadInfoArgs.mixedContentWouldBlock()
|
loadInfoArgs.mixedContentWouldBlock()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include "mozilla/LoadInfo.h"
|
#include "mozilla/LoadInfo.h"
|
||||||
|
|
||||||
#include "mozilla/Assertions.h"
|
#include "mozilla/Assertions.h"
|
||||||
|
#include "mozilla/dom/TabChild.h"
|
||||||
#include "mozilla/dom/ToJSValue.h"
|
#include "mozilla/dom/ToJSValue.h"
|
||||||
#include "mozIThirdPartyUtil.h"
|
#include "mozIThirdPartyUtil.h"
|
||||||
#include "nsFrameLoader.h"
|
#include "nsFrameLoader.h"
|
||||||
|
|
@ -63,6 +64,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
||||||
, mIsThirdPartyContext(false)
|
, mIsThirdPartyContext(false)
|
||||||
, mForcePreflight(false)
|
, mForcePreflight(false)
|
||||||
, mIsPreflight(false)
|
, mIsPreflight(false)
|
||||||
|
, mLoadTriggeredFromExternal(false)
|
||||||
, mForceHSTSPriming(false)
|
, mForceHSTSPriming(false)
|
||||||
, mMixedContentWouldBlock(false)
|
, mMixedContentWouldBlock(false)
|
||||||
{
|
{
|
||||||
|
|
@ -235,6 +237,7 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
|
||||||
, mIsThirdPartyContext(false) // NB: TYPE_DOCUMENT implies not third-party.
|
, mIsThirdPartyContext(false) // NB: TYPE_DOCUMENT implies not third-party.
|
||||||
, mForcePreflight(false)
|
, mForcePreflight(false)
|
||||||
, mIsPreflight(false)
|
, mIsPreflight(false)
|
||||||
|
, mLoadTriggeredFromExternal(false)
|
||||||
, mForceHSTSPriming(false)
|
, mForceHSTSPriming(false)
|
||||||
, mMixedContentWouldBlock(false)
|
, mMixedContentWouldBlock(false)
|
||||||
{
|
{
|
||||||
|
|
@ -297,6 +300,7 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
|
||||||
, mCorsUnsafeHeaders(rhs.mCorsUnsafeHeaders)
|
, mCorsUnsafeHeaders(rhs.mCorsUnsafeHeaders)
|
||||||
, mForcePreflight(rhs.mForcePreflight)
|
, mForcePreflight(rhs.mForcePreflight)
|
||||||
, mIsPreflight(rhs.mIsPreflight)
|
, mIsPreflight(rhs.mIsPreflight)
|
||||||
|
, mLoadTriggeredFromExternal(rhs.mLoadTriggeredFromExternal)
|
||||||
, mForceHSTSPriming(rhs.mForceHSTSPriming)
|
, mForceHSTSPriming(rhs.mForceHSTSPriming)
|
||||||
, mMixedContentWouldBlock(rhs.mMixedContentWouldBlock)
|
, mMixedContentWouldBlock(rhs.mMixedContentWouldBlock)
|
||||||
{
|
{
|
||||||
|
|
@ -325,6 +329,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
||||||
const nsTArray<nsCString>& aCorsUnsafeHeaders,
|
const nsTArray<nsCString>& aCorsUnsafeHeaders,
|
||||||
bool aForcePreflight,
|
bool aForcePreflight,
|
||||||
bool aIsPreflight,
|
bool aIsPreflight,
|
||||||
|
bool aLoadTriggeredFromExternal,
|
||||||
bool aForceHSTSPriming,
|
bool aForceHSTSPriming,
|
||||||
bool aMixedContentWouldBlock)
|
bool aMixedContentWouldBlock)
|
||||||
: mLoadingPrincipal(aLoadingPrincipal)
|
: mLoadingPrincipal(aLoadingPrincipal)
|
||||||
|
|
@ -348,6 +353,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
||||||
, mCorsUnsafeHeaders(aCorsUnsafeHeaders)
|
, mCorsUnsafeHeaders(aCorsUnsafeHeaders)
|
||||||
, mForcePreflight(aForcePreflight)
|
, mForcePreflight(aForcePreflight)
|
||||||
, mIsPreflight(aIsPreflight)
|
, mIsPreflight(aIsPreflight)
|
||||||
|
, mLoadTriggeredFromExternal(aLoadTriggeredFromExternal)
|
||||||
, mForceHSTSPriming (aForceHSTSPriming)
|
, mForceHSTSPriming (aForceHSTSPriming)
|
||||||
, mMixedContentWouldBlock(aMixedContentWouldBlock)
|
, mMixedContentWouldBlock(aMixedContentWouldBlock)
|
||||||
{
|
{
|
||||||
|
|
@ -872,6 +878,23 @@ LoadInfo::GetIsPreflight(bool* aIsPreflight)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
LoadInfo::SetLoadTriggeredFromExternal(bool aLoadTriggeredFromExternal)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(!aLoadTriggeredFromExternal ||
|
||||||
|
mInternalContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT,
|
||||||
|
"can only set load triggered from external for TYPE_DOCUMENT");
|
||||||
|
mLoadTriggeredFromExternal = aLoadTriggeredFromExternal;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
LoadInfo::GetLoadTriggeredFromExternal(bool* aLoadTriggeredFromExternal)
|
||||||
|
{
|
||||||
|
*aLoadTriggeredFromExternal = mLoadTriggeredFromExternal;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LoadInfo::GetForceHSTSPriming(bool* aForceHSTSPriming)
|
LoadInfo::GetForceHSTSPriming(bool* aForceHSTSPriming)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ private:
|
||||||
const nsTArray<nsCString>& aUnsafeHeaders,
|
const nsTArray<nsCString>& aUnsafeHeaders,
|
||||||
bool aForcePreflight,
|
bool aForcePreflight,
|
||||||
bool aIsPreflight,
|
bool aIsPreflight,
|
||||||
|
bool aLoadTriggeredFromExternal,
|
||||||
bool aForceHSTSPriming,
|
bool aForceHSTSPriming,
|
||||||
bool aMixedContentWouldBlock);
|
bool aMixedContentWouldBlock);
|
||||||
LoadInfo(const LoadInfo& rhs);
|
LoadInfo(const LoadInfo& rhs);
|
||||||
|
|
@ -152,6 +153,7 @@ private:
|
||||||
nsTArray<nsCString> mCorsUnsafeHeaders;
|
nsTArray<nsCString> mCorsUnsafeHeaders;
|
||||||
bool mForcePreflight;
|
bool mForcePreflight;
|
||||||
bool mIsPreflight;
|
bool mIsPreflight;
|
||||||
|
bool mLoadTriggeredFromExternal;
|
||||||
|
|
||||||
bool mForceHSTSPriming : 1;
|
bool mForceHSTSPriming : 1;
|
||||||
bool mMixedContentWouldBlock : 1;
|
bool mMixedContentWouldBlock : 1;
|
||||||
|
|
|
||||||
|
|
@ -574,6 +574,13 @@ interface nsILoadInfo : nsISupports
|
||||||
*/
|
*/
|
||||||
[infallible] attribute boolean initialSecurityCheckDone;
|
[infallible] attribute boolean initialSecurityCheckDone;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the load was triggered from an external application
|
||||||
|
* (e.g. Thunderbird). Please note that this flag will only ever be true
|
||||||
|
* if the load is of TYPE_DOCUMENT.
|
||||||
|
*/
|
||||||
|
[infallible] attribute boolean loadTriggeredFromExternal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whenever a channel gets redirected, append the principal of the
|
* Whenever a channel gets redirected, append the principal of the
|
||||||
* channel [before the channels got redirected] to the loadinfo,
|
* channel [before the channels got redirected] to the loadinfo,
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ struct LoadInfoArgs
|
||||||
nsCString[] corsUnsafeHeaders;
|
nsCString[] corsUnsafeHeaders;
|
||||||
bool forcePreflight;
|
bool forcePreflight;
|
||||||
bool isPreflight;
|
bool isPreflight;
|
||||||
|
bool loadTriggeredFromExternal;
|
||||||
bool forceHSTSPriming;
|
bool forceHSTSPriming;
|
||||||
bool mixedContentWouldBlock;
|
bool mixedContentWouldBlock;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue