mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
moebius#230: Consider blocking top level window data: URIs (part 3/3 without tests)
https://github.com/MoonchildProductions/moebius/pull/230
This commit is contained in:
parent
73f89fe562
commit
18d312235d
20 changed files with 143 additions and 3 deletions
|
|
@ -1273,6 +1273,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
nsCOMPtr<nsISHEntry> shEntry;
|
||||
nsXPIDLString target;
|
||||
nsAutoString srcdoc;
|
||||
bool forceAllowDataURI = false;
|
||||
nsCOMPtr<nsIDocShell> sourceDocShell;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
|
||||
|
|
@ -1308,6 +1309,7 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
aLoadInfo->GetSrcdocData(srcdoc);
|
||||
aLoadInfo->GetSourceDocShell(getter_AddRefs(sourceDocShell));
|
||||
aLoadInfo->GetBaseURI(getter_AddRefs(baseURI));
|
||||
aLoadInfo->GetForceAllowDataURI(&forceAllowDataURI);
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
|
@ -1561,6 +1563,10 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
flags |= INTERNAL_LOAD_FLAGS_IS_SRCDOC;
|
||||
}
|
||||
|
||||
if (forceAllowDataURI) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI;
|
||||
}
|
||||
|
||||
return InternalLoad(aURI,
|
||||
originalURI,
|
||||
loadReplace,
|
||||
|
|
@ -4822,6 +4828,9 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
|
|||
}
|
||||
nsAutoPopupStatePusher statePusher(popupState);
|
||||
|
||||
bool forceAllowDataURI =
|
||||
aLoadFlags & LOAD_FLAGS_FORCE_ALLOW_DATA_URI;
|
||||
|
||||
// Don't pass certain flags that aren't needed and end up confusing
|
||||
// ConvertLoadTypeToDocShellLoadInfo. We do need to ensure that they are
|
||||
// passed to LoadURI though, since it uses them.
|
||||
|
|
@ -4851,6 +4860,7 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
|
|||
loadInfo->SetReferrerPolicy(aReferrerPolicy);
|
||||
loadInfo->SetHeadersStream(aHeaderStream);
|
||||
loadInfo->SetBaseURI(aBaseURI);
|
||||
loadInfo->SetForceAllowDataURI(forceAllowDataURI);
|
||||
|
||||
if (fixupInfo) {
|
||||
nsAutoString searchProvider, keyword;
|
||||
|
|
@ -10083,6 +10093,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
// principal to inherit is: it should be aTriggeringPrincipal.
|
||||
loadInfo->SetPrincipalIsExplicit(true);
|
||||
loadInfo->SetLoadType(ConvertLoadTypeToDocShellLoadInfo(LOAD_LINK));
|
||||
loadInfo->SetForceAllowDataURI(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI);
|
||||
|
||||
rv = win->Open(NS_ConvertUTF8toUTF16(spec),
|
||||
aWindowTarget, // window name
|
||||
|
|
@ -10728,7 +10739,9 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
nsINetworkPredictor::PREDICT_LOAD, this, nullptr);
|
||||
|
||||
nsCOMPtr<nsIRequest> req;
|
||||
rv = DoURILoad(aURI, aOriginalURI, aLoadReplace, loadFromExternal, aReferrer,
|
||||
rv = DoURILoad(aURI, aOriginalURI, aLoadReplace, loadFromExternal,
|
||||
(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI),
|
||||
aReferrer,
|
||||
!(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
|
||||
aReferrerPolicy,
|
||||
aTriggeringPrincipal, principalToInherit, aTypeHint,
|
||||
|
|
@ -10809,6 +10822,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
|||
nsIURI* aOriginalURI,
|
||||
bool aLoadReplace,
|
||||
bool aLoadFromExternal,
|
||||
bool aForceAllowDataURI,
|
||||
nsIURI* aReferrerURI,
|
||||
bool aSendReferrer,
|
||||
uint32_t aReferrerPolicy,
|
||||
|
|
@ -10954,6 +10968,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
|||
loadInfo->SetPrincipalToInherit(aPrincipalToInherit);
|
||||
}
|
||||
loadInfo->SetLoadTriggeredFromExternal(aLoadFromExternal);
|
||||
loadInfo->SetForceAllowDataURI(aForceAllowDataURI);
|
||||
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -370,6 +370,7 @@ protected:
|
|||
nsIURI* aOriginalURI,
|
||||
bool aLoadReplace,
|
||||
bool aLoadFromExternal,
|
||||
bool aForceAllowDataURI,
|
||||
nsIURI* aReferrer,
|
||||
bool aSendReferrer,
|
||||
uint32_t aReferrerPolicy,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ nsDocShellLoadInfo::nsDocShellLoadInfo()
|
|||
: mLoadReplace(false)
|
||||
, mInheritPrincipal(false)
|
||||
, mPrincipalIsExplicit(false)
|
||||
, mForceAllowDataURI(false)
|
||||
, mSendReferrer(true)
|
||||
, mReferrerPolicy(mozilla::net::RP_Default)
|
||||
, mLoadType(nsIDocShellLoadInfo::loadNormal)
|
||||
|
|
@ -126,6 +127,20 @@ nsDocShellLoadInfo::SetPrincipalIsExplicit(bool aPrincipalIsExplicit)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetForceAllowDataURI(bool* aForceAllowDataURI)
|
||||
{
|
||||
*aForceAllowDataURI = mForceAllowDataURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::SetForceAllowDataURI(bool aForceAllowDataURI)
|
||||
{
|
||||
mForceAllowDataURI = aForceAllowDataURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType* aLoadType)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ protected:
|
|||
bool mLoadReplace;
|
||||
bool mInheritPrincipal;
|
||||
bool mPrincipalIsExplicit;
|
||||
bool mForceAllowDataURI;
|
||||
bool mSendReferrer;
|
||||
nsDocShellInfoReferrerPolicy mReferrerPolicy;
|
||||
nsDocShellInfoLoadType mLoadType;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,9 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
|
||||
const long INTERNAL_LOAD_FLAGS_NO_OPENER = 0x100;
|
||||
|
||||
// Whether a top-level data URI navigation is allowed for that load
|
||||
const long INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x200;
|
||||
|
||||
// NB: 0x80 is available.
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -55,6 +55,12 @@ interface nsIDocShellLoadInfo : nsISupports
|
|||
*/
|
||||
attribute boolean principalIsExplicit;
|
||||
|
||||
/**
|
||||
* If this attribute is true, then a top-level navigation
|
||||
* to a data URI will be allowed.
|
||||
*/
|
||||
attribute boolean forceAllowDataURI;
|
||||
|
||||
/* these are load type enums... */
|
||||
const long loadNormal = 0; // Normal Load
|
||||
const long loadNormalReplace = 1; // Normal Load but replaces current history slot
|
||||
|
|
|
|||
|
|
@ -205,6 +205,12 @@ interface nsIWebNavigation : nsISupports
|
|||
*/
|
||||
const unsigned long LOAD_FLAGS_FIXUP_SCHEME_TYPOS = 0x200000;
|
||||
|
||||
/**
|
||||
* Allows a top-level data: navigation to occur. E.g. view-image
|
||||
* is an explicit user action which should be allowed.
|
||||
*/
|
||||
const unsigned long LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x400000;
|
||||
|
||||
/**
|
||||
* Loads a given URI. This will give priority to loading the requested URI
|
||||
* in the object implementing this interface. If it can't be loaded here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue