Bug 1641303 - Use query and ref lengths if available. r=mayhemer,necko-reviewers, a=jcristau
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 17 Jun 2020 08:29:21 +0000
changeset 524862 701d20f4cfb68b411d2565388158ddd925db6940
parent 524861 f60d8342433b0e9e25f2c98dc63fc98dc058fe9c
child 524863 bb8e48d86ba0049c95b67fdf45990b186f883517
push id1059
push userjcristau@mozilla.com
push dateThu, 18 Jun 2020 12:37:14 +0000
treeherdermozilla-esr68@701d20f4cfb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer, necko-reviewers, jcristau
bugs1641303
milestone68.10.0
Bug 1641303 - Use query and ref lengths if available. r=mayhemer,necko-reviewers, a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D77418
netwerk/base/nsStandardURL.cpp
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -2687,18 +2687,21 @@ nsresult nsStandardURL::SetFilePath(cons
     }
 
     return SetSpecInternal(spec);
   }
   if (mPath.mLen > 1) {
     mSpec.Cut(mPath.mPos + 1, mFilepath.mLen - 1);
     // left shift query, and ref
     ShiftFromQuery(1 - mFilepath.mLen);
+    // One character for '/', and if we have a query or ref we add their
+    // length and one extra for each '?' or '#' characters
+    mPath.mLen = 1 + (mQuery.mLen >= 0 ? (mQuery.mLen + 1) : 0) +
+                 (mRef.mLen >= 0 ? (mRef.mLen + 1) : 0);
     // these contain only a '/'
-    mPath.mLen = 1;
     mDirectory.mLen = 1;
     mFilepath.mLen = 1;
     // these are no longer defined
     mBasename.mLen = -1;
     mExtension.mLen = -1;
   }
   return NS_OK;
 }