LibWeb/HTML: Explicitly basic parse URL when following the hyperlink

Instead of relying on the implicit URL constuctor. Parsing should
never fail here as urlString before adding the suffix is already
parsed above, and the suffix should only be a valid query string.
This commit is contained in:
Shannon Booth 2025-02-22 20:28:47 +13:00 committed by Tim Flynn
parent 2827374edc
commit 1257d0c1a8
Notes: github-actions[bot] 2025-03-04 21:26:33 +00:00

View file

@ -518,7 +518,9 @@ void HTMLHyperlinkElementUtils::follow_the_hyperlink(Optional<String> hyperlink_
// FIXME: 12. If subject's link types includes the noreferrer keyword, then set referrerPolicy to "no-referrer".
// 13. Navigate targetNavigable to urlString using subject's node document, with referrerPolicy set to referrerPolicy and userInvolvement set to userInvolvement.
MUST(target_navigable->navigate({ .url = url_string, .source_document = hyperlink_element_utils_document(), .referrer_policy = referrer_policy, .user_involvement = user_involvement }));
auto url = URL::Parser::basic_parse(url_string);
VERIFY(url.has_value());
MUST(target_navigable->navigate({ .url = url.release_value(), .source_document = hyperlink_element_utils_document(), .referrer_policy = referrer_policy, .user_involvement = user_involvement }));
}
}