Bug 1142083 - IDN Unicode domain redirect is broken r=mcmanus
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 18 Jun 2015 16:05:21 +0300
changeset 280371 6c782e3a7078ef6ee8cbae43271b5f0f55d7b92b
parent 280370 a7519734ac5bfddf3001694098fe992b8023e251
child 280372 7a4447a6be71503e5abf9949b84f4e0e8cf53ea0
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1142083
milestone41.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 1142083 - IDN Unicode domain redirect is broken r=mcmanus
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -4431,16 +4431,32 @@ nsHttpChannel::AsyncProcessRedirection(u
 
     nsresult rv = CreateNewURI(location, getter_AddRefs(mRedirectURI));
 
     if (NS_FAILED(rv)) {
         LOG(("Invalid URI for redirect: Location: %s\n", location));
         return NS_ERROR_CORRUPTED_CONTENT;
     }
 
+    nsAutoCString redirectHost;
+    mRedirectURI->GetHost(redirectHost);
+    nsAutoCString currentHost;
+    mURI->GetHost(currentHost);
+    if (redirectHost != currentHost) {
+        // When redirecting to another domain, the target domain should not be
+        // percent encoded, as the URL parser does not yet support that
+        nsAutoCString unescapedHost;
+        if (NS_UnescapeURL(redirectHost.BeginReading(), redirectHost.Length(),
+                           0, unescapedHost)) {
+            if (IsUTF8(unescapedHost)) {
+                mRedirectURI->SetHost(unescapedHost);
+            }
+        }
+    }
+
     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;
             (void)ProcessFallback(&waitingForRedirectCallback);