mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
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`.
This commit is contained in:
parent
fd042dce55
commit
caa13bf41d
Notes:
sideshowbarker
2024-07-17 08:35:21 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/caa13bf41d Pull-request: https://github.com/SerenityOS/serenity/pull/15795 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/davidot ✅
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/URLParser.h>
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
|
@ -103,7 +104,8 @@ ErrorOr<Optional<AK::URL>> Response::location_url(Optional<String> const& reques
|
|||
return Optional<AK::URL> {};
|
||||
|
||||
// 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue