Bug 585869 - Check for file scheme in nsResURL::EnsureFile, r=bsmedberg a=blocking2.0
authorMichael Wu <mwu@mozilla.com>
Tue, 10 Aug 2010 15:03:26 -0700
changeset 49359 7d3a8767a03be6de7488a7ce7b8b7585d39eab37
parent 49358 c858e22f380ffcda36d0328f682bb7aea429715d
child 49360 f80832cefeb5ae5743147b2175a690ed4816a8e0
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, blocking2.0
bugs585869
milestone2.0b4pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 585869 - Check for file scheme in nsResURL::EnsureFile, r=bsmedberg a=blocking2.0
netwerk/protocol/res/nsResProtocolHandler.cpp
--- a/netwerk/protocol/res/nsResProtocolHandler.cpp
+++ b/netwerk/protocol/res/nsResProtocolHandler.cpp
@@ -90,35 +90,30 @@ nsresult
 nsResURL::EnsureFile()
 {
     nsresult rv;
 
     NS_ENSURE_TRUE(gResHandler, NS_ERROR_NOT_AVAILABLE);
 
     nsCAutoString spec;
     rv = gResHandler->ResolveURI(this, spec);
-    if (NS_FAILED(rv)) return rv;
+    if (NS_FAILED(rv))
+        return rv;
 
-#if defined(MOZ_CHROME_FILE_FORMAT_JAR) || defined(MOZ_OMNIJAR)
-    nsCAutoString host;
-    rv = GetHost(host);
+    nsCAutoString scheme;
+    rv = net_ExtractURLScheme(spec, nsnull, nsnull, &scheme);
     if (NS_FAILED(rv))
         return rv;
-    // Deal with the fact resource://gre-resouces/ urls do not resolve to files
-    if (host.Equals(kGRE_RESOURCES))
+
+    // 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
     if (NS_SUCCEEDED(rv)) {
         PRBool exists = PR_TRUE;
         mFile->Exists(&exists);
         if (!exists) {
             printf("resource %s doesn't exist!\n", spec.get());