Bug 1435772 - File extensions are stripped out from saved web page source, leading to 404 errors r=me
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 07 Feb 2018 17:30:13 +0100
changeset 402785 73c9ae92a86e0a83491f0dac5a96ee0a5c4e0097
parent 402784 21f35c5ec16771aaf32b82d4afc2f7021dc65fcb
child 402786 d24c555a59d87a3bc676332cf9120ece787e3b05
push id33402
push useraciure@mozilla.com
push dateWed, 07 Feb 2018 22:06:27 +0000
treeherdermozilla-central@8cc2427a322c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1435772, 1432602
milestone60.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 1435772 - File extensions are stripped out from saved web page source, leading to 404 errors r=me Backs out the part of part of changeset a20fbbe7b948 (Bug 1432602) that uses nsIURIMutator instead of calling nsIFileURL::SetFile() MozReview-Commit-ID: 9mC3fv85pUl
dom/webbrowserpersist/nsWebBrowserPersist.cpp
--- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp
+++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp
@@ -2108,20 +2108,20 @@ nsWebBrowserPersist::CalculateUniqueFile
 
         if (localFile)
         {
             nsAutoString filenameAsUnichar;
             CopyASCIItoUTF16(filename, filenameAsUnichar);
             localFile->SetLeafName(filenameAsUnichar);
 
             // Resync the URI with the file after the extension has been appended
-            return NS_MutateURI(aURI)
-                     .Apply<nsIFileURLMutator>(&nsIFileURLMutator::SetFile,
-                                               localFile)
-                     .Finalize(aOutURI);
+            nsresult rv;
+            nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aURI, &rv);
+            NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
+            fileURL->SetFile(localFile);  // this should recalculate uri
         }
         else
         {
             return NS_MutateURI(url)
                      .Apply<nsIURLMutator>(&nsIURLMutator::SetFileName,
                                            filename,
                                            nullptr)
                      .Finalize(aOutURI);
@@ -2287,20 +2287,19 @@ nsWebBrowserPersist::CalculateAndAppendF
                     newFileName.Append(fileExt);
                 }
 
                 if (localFile)
                 {
                     localFile->SetLeafName(NS_ConvertUTF8toUTF16(newFileName));
 
                     // Resync the URI with the file after the extension has been appended
-                    return NS_MutateURI(aURI)
-                             .Apply<nsIFileURLMutator>(&nsIFileURLMutator::SetFile,
-                                                   localFile)
-                             .Finalize(aOutURI);
+                    nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aURI, &rv);
+                    NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
+                    fileURL->SetFile(localFile);  // this should recalculate uri
                 }
                 else
                 {
                     return NS_MutateURI(url)
                              .Apply<nsIURLMutator>(&nsIURLMutator::SetFileName,
                                                    newFileName,
                                                    nullptr)
                              .Finalize(aOutURI);