ported follow-ups of "Bug 1143922 - Add AsyncOpen2 to nsIChannel and perform security checks when opening a channel - scriptSecurityManager changes (r=sicking,bholley)":

- Bug 1184387 - Bail out of file:// loads for all non-chrome:// URIs. r=Gijs
- Bug 1224046 - Remove <base href> from directory listings. r=mcmanus

but this doesn't solve ask-to-activate plugin issue.
This commit is contained in:
2021-10-29 14:49:12 +08:00
parent 4e0540b821
commit dbff702211
2 changed files with 3 additions and 33 deletions
+3 -9
View File
@@ -863,18 +863,12 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
}
}
// resource: and chrome: are equivalent, securitywise
// That's bogus!! Fix this. But watch out for
// the view-source stylesheet?
bool sourceIsChrome;
rv = NS_URIChainHasFlags(sourceURI,
nsIProtocolHandler::URI_IS_UI_RESOURCE,
&sourceIsChrome);
NS_ENSURE_SUCCESS(rv, rv);
if (sourceIsChrome) {
// Allow chrome://
if (sourceScheme.EqualsLiteral("chrome")) {
return NS_OK;
}
// Nothing else.
if (reportErrors) {
ReportError(nullptr, errorTag, sourceURI, aTargetURI);
}
@@ -533,30 +533,6 @@ nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, nsISupports *aContext,
buffer.AppendLiteral("</title>\n");
// If there is a quote character in the baseUri, then
// lets not add a base URL. The reason for this is that
// if we stick baseUri containing a quote into a quoted
// string, the quote character will prematurely close
// the base href string. This is a fall-back check;
// that's why it is OK to not use a base rather than
// trying to play nice and escaping the quotes. See bug
// 358128.
if (baseUri.FindChar('"') == kNotFound)
{
// Great, the baseUri does not contain a char that
// will prematurely close the string. Go ahead an
// add a base href.
buffer.AppendLiteral("<base href=\"");
nsAdoptingCString htmlEscapedUri(nsEscapeHTML(baseUri.get()));
buffer.Append(htmlEscapedUri);
buffer.AppendLiteral("\" />\n");
}
else
{
NS_ERROR("broken protocol handler didn't escape double-quote.");
}
nsCString direction(NS_LITERAL_CSTRING("ltr"));
nsCOMPtr<nsIXULChromeRegistry> reg =
mozilla::services::GetXULChromeRegistryService();