From 699c96697a6d3e3a05757167242cec2fd15fb67c Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Tue, 10 Aug 2010 15:03:26 -0700 Subject: [PATCH] Bug 585869 - Check for file scheme in nsResURL::EnsureFile, r=bsmedberg a=blocking2.0 --- netwerk/protocol/res/nsResProtocolHandler.cpp | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/netwerk/protocol/res/nsResProtocolHandler.cpp b/netwerk/protocol/res/nsResProtocolHandler.cpp index 8122c0d6405d..12f74e1ca84c 100644 --- a/netwerk/protocol/res/nsResProtocolHandler.cpp +++ b/netwerk/protocol/res/nsResProtocolHandler.cpp @@ -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