Bug 1224046 - Remove <base href> from directory listings. r=mcmanus

There was an attempt to remove it in bug 358128, but that was backed out
because of FTP listings, where e.g. a 'mozilla' link on the
ftp://ftp.mozilla.org/pub listing (without a trailing slash) would go to
ftp://ftp.mozilla.org/pubmozilla instead of ftp://ftp.mozilla.org/pub/mozilla.

It appears that versions of Firefox at the time of that bug wouldn't "redirect"
directories to the same url with a trailing slash when one was not provided.
It also appears that current versions of Firefox *do* "redirect" in such a way,
such that the <base href> is now unnecessary.

That <base href> prevents links from resource://... directory listings to work
properly because of security contraints added in bug 1184387, as they force
links to go to a jar/file url instead of the equivalent resource://... url,
which removing <base href> allows.
This commit is contained in:
Mike Hommey 2015-11-12 18:00:15 +09:00
Родитель ea64674637
Коммит 329021a041
1 изменённых файлов: 0 добавлений и 24 удалений

Просмотреть файл

@ -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.Contains('"'))
{
// 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();