1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

AK: Write scheme state of URL parsing closer to spec steps

The main change here is that we now follow the spec by asserting the URL
is not special. Previously I could not find a way to enable this without
getting assertions when browsing the web - but that seems to no longer
be the case (probably from some other fixes which have since been made).
This commit is contained in:
Shannon Booth 2023-08-13 11:08:12 +12:00 committed by Andrew Kaster
parent 23e82114b4
commit f53dfdd6ac

View file

@ -875,18 +875,17 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
state = State::File; state = State::File;
} }
// 6. Otherwise, if url is special, base is non-null, and bases scheme is urls scheme: // 6. Otherwise, if url is special, base is non-null, and bases scheme is urls scheme:
// 7. Otherwise, if url is special, set state to special authority slashes state. else if (url->is_special() && base_url.has_value() && base_url->scheme() == url->m_scheme) {
// FIXME: Write this block closer to spec text. // 1. Assert: base is is special (and therefore does not have an opaque path).
else if (url->is_special()) { VERIFY(base_url->is_special());
// FIXME: 1. Assert: base is is special (and therefore does not have an opaque path).
// 2. Set state to special relative or authority state. // 2. Set state to special relative or authority state.
if (base_url.has_value() && base_url->m_scheme == url->m_scheme) state = State::SpecialRelativeOrAuthority;
state = State::SpecialRelativeOrAuthority; }
else // 7. Otherwise, if url is special, set state to special authority slashes state.
state = State::SpecialAuthoritySlashes; else if (url->is_special()) {
state = State::SpecialAuthoritySlashes;
} }
// 8. Otherwise, if remaining starts with an U+002F (/), set state to path or authority state and increase pointer by 1. // 8. Otherwise, if remaining starts with an U+002F (/), set state to path or authority state and increase pointer by 1.
else if (get_remaining().starts_with("/"sv)) { else if (get_remaining().starts_with("/"sv)) {
state = State::PathOrAuthority; state = State::PathOrAuthority;