From c19627f880273207126b5c512447ef3057365640 Mon Sep 17 00:00:00 2001 From: Honza Bambas Date: Wed, 20 Jan 2016 20:02:23 +0100 Subject: [PATCH] Bug 451081 - Introduce ORIGIN_IS_FULL_SPEC protocol handler flag, r=bz+standard8 IGNORE IDL --- netwerk/base/nsIProtocolHandler.idl | 8 ++++++++ netwerk/base/nsNetUtil.cpp | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/netwerk/base/nsIProtocolHandler.idl b/netwerk/base/nsIProtocolHandler.idl index 21b1517cdecb..ddf8cf57b512 100644 --- a/netwerk/base/nsIProtocolHandler.idl +++ b/netwerk/base/nsIProtocolHandler.idl @@ -294,6 +294,12 @@ interface nsIProtocolHandler : nsISupports * headers. */ const unsigned long URI_FETCHABLE_BY_ANYONE = (1 << 19); + + /** + * If this flag is set, then the origin for this protocol is the full URI + * spec, not just the scheme + host + port. + */ + const unsigned long ORIGIN_IS_FULL_SPEC = (1 << 20); }; %{C++ @@ -304,4 +310,6 @@ interface nsIProtocolHandler : nsISupports /** * For example, "@mozilla.org/network/protocol;1?name=http" */ + +#define IS_ORIGIN_IS_FULL_SPEC_DEFINED 1 %} diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index ca45435d2523..43e6f880ed98 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -1646,9 +1646,10 @@ NS_SecurityHashURI(nsIURI *aURI) if (scheme.EqualsLiteral("file")) return schemeHash; // sad face - if (scheme.EqualsLiteral("imap") || - scheme.EqualsLiteral("mailbox") || - scheme.EqualsLiteral("news")) + bool hasFlag; + if (NS_FAILED(NS_URIChainHasFlags(baseURI, + nsIProtocolHandler::ORIGIN_IS_FULL_SPEC, &hasFlag)) || + hasFlag) { nsAutoCString spec; uint32_t specHash; @@ -1745,13 +1746,13 @@ NS_SecurityCompareURIs(nsIURI *aSourceURI, return NS_SUCCEEDED(rv) && filesAreEqual; } - // Special handling for mailnews schemes - if (targetScheme.EqualsLiteral("imap") || - targetScheme.EqualsLiteral("mailbox") || - targetScheme.EqualsLiteral("news")) + bool hasFlag; + if (NS_FAILED(NS_URIChainHasFlags(targetBaseURI, + nsIProtocolHandler::ORIGIN_IS_FULL_SPEC, &hasFlag)) || + hasFlag) { - // Each message is a distinct trust domain; use the - // whole spec for comparison + // URIs with this flag have the whole spec as a distinct trust + // domain; use the whole spec for comparison nsAutoCString targetSpec; nsAutoCString sourceSpec; return ( NS_SUCCEEDED( targetBaseURI->GetSpec(targetSpec) ) &&