Bug 585869 - Check for file scheme in nsResURL::EnsureFile, r=bsmedberg a=blocking2.0

This commit is contained in:
Michael Wu 2010-08-10 15:03:26 -07:00
Родитель 82c4fde3eb
Коммит 699c96697a
1 изменённых файлов: 11 добавлений и 16 удалений

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

@ -95,25 +95,20 @@ nsResURL::EnsureFile()
nsCAutoString spec;
rv = gResHandler->ResolveURI(this, spec);
if (NS_FAILED(rv)) return rv;
#if defined(MOZ_CHROME_FILE_FORMAT_JAR) || defined(MOZ_OMNIJAR)
nsCAutoString host;
rv = GetHost(host);
if (NS_FAILED(rv))
return rv;
// Deal with the fact resource://gre-resouces/ urls do not resolve to files
if (host.Equals(kGRE_RESOURCES))
nsCAutoString scheme;
rv = net_ExtractURLScheme(spec, nsnull, nsnull, &scheme);
if (NS_FAILED(rv))
return rv;
// Bug 585869:
// In most cases, the scheme is jar if it's not file.
// Regardless, net_GetFileFromURLSpec should be avoided
// when the scheme isn't file.
if (!scheme.Equals(NS_LITERAL_CSTRING("file")))
return NS_ERROR_NO_INTERFACE;
#endif
#ifdef MOZ_OMNIJAR
if (mozilla::OmnijarPath()) {
if (host.Equals(kGRE))
return NS_ERROR_NO_INTERFACE;
if (host.IsEmpty())
return NS_ERROR_NO_INTERFACE;
}
#endif
rv = net_GetFileFromURLSpec(spec, getter_AddRefs(mFile));
#ifdef DEBUG_bsmedberg