From d55111c4fd1b20e2ec291788721a2adbe2370956 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 23 Nov 2023 16:08:26 +0100 Subject: [PATCH] [Network] Fix relative URL path starting with multiple slashes --- netwerk/base/nsStandardURL.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index aa60b52cd5..9334def6c7 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -2541,7 +2541,15 @@ nsStandardURL::Resolve(const nsACString &in, nsACString &out) // locate result path resultPath = PL_strstr(result, "://"); if (resultPath) { - resultPath = PL_strchr(resultPath + 3, '/'); + // If there are multiple slashes after :// we must ignore them + // otherwise net_CoalesceDirs may think the host is a part of the path. + resultPath += 3; + if (protocol.IsEmpty() && !SegmentIs(mScheme,"file")) { + while (*resultPath == '/') { + resultPath++; + } + } + resultPath = PL_strchr(resultPath, '/'); if (resultPath) net_CoalesceDirs(coalesceFlag,resultPath); }