Bug 867407 - Fix cloning of file URIs with search query strings (r=sworkman)
authorBill McCloskey <billm@mozilla.com>
Thu, 29 Oct 2015 14:13:23 -0700
changeset 270430 16ab2ae184c0c4e46d174326cecb5191633e6a09
parent 270429 d68a55e2c1baaa6376b1b5fc4c24c38d1f53dff9
child 270431 7ecec6573ae9e323ea1f4ca401d160ad776405a6
push id67367
push userwmccloskey@mozilla.com
push dateFri, 30 Oct 2015 20:10:32 +0000
treeherdermozilla-inbound@16ab2ae184c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssworkman
bugs867407
milestone45.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 867407 - Fix cloning of file URIs with search query strings (r=sworkman)
netwerk/protocol/file/nsFileChannel.cpp
--- a/netwerk/protocol/file/nsFileChannel.cpp
+++ b/netwerk/protocol/file/nsFileChannel.cpp
@@ -267,16 +267,24 @@ nsFileChannel::nsFileChannel(nsIURI *uri
       NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) &&
       NS_SUCCEEDED(file->IsSymlink(&symLink)) && 
       symLink &&
       NS_SUCCEEDED(file->GetNativeTarget(fileTarget)) &&
       NS_SUCCEEDED(NS_NewNativeLocalFile(fileTarget, PR_TRUE, 
                                          getter_AddRefs(resolvedFile))) &&
       NS_SUCCEEDED(NS_NewFileURI(getter_AddRefs(targetURI), 
                    resolvedFile, nullptr))) {
+    // Make an effort to match up the query strings.
+    nsCOMPtr<nsIURL> origURL = do_QueryInterface(uri);
+    nsCOMPtr<nsIURL> targetURL = do_QueryInterface(targetURI);
+    nsAutoCString queryString;
+    if (origURL && targetURL && NS_SUCCEEDED(origURL->GetQuery(queryString))) {
+      targetURL->SetQuery(queryString);
+    }
+
     SetURI(targetURI);
     SetOriginalURI(uri);
     nsLoadFlags loadFlags = 0;
     GetLoadFlags(&loadFlags);
     SetLoadFlags(loadFlags | nsIChannel::LOAD_REPLACE);
   } else {
     SetURI(uri);
   }