Bug 738484 - Handle Location: that won't parse to valid URI. r=mcmanus
authorJason Duell <jduell.mcbugs@gmail.com>
Wed, 11 Apr 2012 13:26:23 -0700
changeset 91459 7814c8fdc48b5e13074217a53185ad63034baa7f
parent 91458 6d83a00be8a0d0fa5efadc5f4be5ef25f649f6af
child 91460 66e7ce7034c7d63d92b9f56be337b21b8c340415
push id22445
push usereakhgari@mozilla.com
push dateThu, 12 Apr 2012 16:19:55 +0000
treeherdermozilla-central@901dfde60183 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs738484
milestone14.0a1
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 738484 - Handle Location: that won't parse to valid URI. r=mcmanus
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -1144,16 +1144,21 @@ nsHttpChannel::ProcessResponse()
     }
 
     return rv;
 }
 
 nsresult
 nsHttpChannel::ContinueProcessResponse(nsresult rv)
 {
+    if (rv == NS_ERROR_CORRUPTED_CONTENT) {
+        // don't ever render responses we've flagged as suspect content
+        return NS_ERROR_CORRUPTED_CONTENT;
+    }
+
     if (rv == NS_ERROR_DOM_BAD_URI && mRedirectURI) {
 
         bool isHTTP = false;
         if (NS_FAILED(mRedirectURI->SchemeIs("http", &isHTTP)))
             isHTTP = false;
         if (!isHTTP && NS_FAILED(mRedirectURI->SchemeIs("https", &isHTTP)))
             isHTTP = false;
         
@@ -3521,17 +3526,21 @@ nsHttpChannel::AsyncProcessRedirection(P
 
     mRedirectType = redirectType;
 
     LOG(("redirecting to: %s [redirection-limit=%u]\n",
         location, PRUint32(mRedirectionLimit)));
 
     nsresult rv = CreateNewURI(location, getter_AddRefs(mRedirectURI));
 
-    if (NS_FAILED(rv)) return rv;
+    if (NS_FAILED(rv)) {
+        LOG(("Invalid URI for redirect: Location: %s\n", location));
+        Cancel(NS_ERROR_CORRUPTED_CONTENT);
+        return NS_ERROR_CORRUPTED_CONTENT;
+    }
 
     if (mApplicationCache) {
         // if we are redirected to a different origin check if there is a fallback
         // cache entry to fall back to. we don't care about file strict 
         // checking, at least mURI is not a file URI.
         if (!NS_SecurityCompareURIs(mURI, mRedirectURI, false)) {
             PushRedirectAsyncFunc(&nsHttpChannel::ContinueProcessRedirectionAfterFallback);
             bool waitingForRedirectCallback;