From caa13bf41d4af83f5b18e71b23d0ce6f24501b09 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 25 Oct 2022 23:03:54 +0100 Subject: [PATCH] LibWeb: Fix URL parsing in Response::location_url() We need to use URLParser in order to provide a base URL. This makes it work for the common case of `Location: /some/path`. --- .../Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp index f800ab44ed..679bf100db 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -103,7 +104,8 @@ ErrorOr> Response::location_url(Optional const& reques return Optional {}; // 3. If location is a header value, then set location to the result of parsing location with response’s URL. - auto location = AK::URL { StringView { location_values->first() } }; + auto base_url = *url(); + auto location = AK::URLParser::parse(location_values->first(), &base_url); if (!location.is_valid()) return Error::from_string_view("Invalid 'Location' header URL"sv);