Bug 1232287 - revert bug 1224046 and fix resource: URIs to not have a base tag, r=glandium,valentin

--HG--
extra : rebase_source : 66d108d2bd4d17306df3ec3e259c9f69772613b1
This commit is contained in:
Gijs Kruitbosch 2015-12-15 12:09:05 +00:00
parent bf668586d7
commit 06c03baf6f

View File

@ -533,6 +533,38 @@ 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.Contains('"'))
{
// Great, the baseUri does not contain a char that
// will prematurely close the string. Go ahead an
// add a base href, but only do so if we're not
// dealing with a resource URI.
nsCOMPtr<nsIURI> originalUri;
rv = channel->GetOriginalURI(getter_AddRefs(originalUri));
bool wasResource = false;
if (NS_FAILED(rv) ||
NS_FAILED(originalUri->SchemeIs("resource", &wasResource)) ||
!wasResource) {
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();