mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 17:15:09 +00:00
AK: Correct faulty logic in file slash state in basic URL parsing
We were not correctly decrementing the pointer in the case that either the base URL was non-null or the base URL's scheme was not a file.
This commit is contained in:
parent
a809d1634f
commit
b76972ff32
1 changed files with 12 additions and 11 deletions
|
@ -823,22 +823,23 @@ URL URLParser::parse(StringView raw_input, Optional<URL> const& base_url, Option
|
||||||
state = State::FileHost;
|
state = State::FileHost;
|
||||||
}
|
}
|
||||||
// 2. Otherwise:
|
// 2. Otherwise:
|
||||||
// 1. If base is non-null and base’s scheme is "file", then:
|
else {
|
||||||
else if (base_url.has_value() && base_url->m_scheme == "file") {
|
// 1. If base is non-null and base’s scheme is "file", then:
|
||||||
// 1. Set url’s host to base’s host.
|
if (base_url.has_value() && base_url->m_scheme == "file") {
|
||||||
url->m_paths = base_url->m_paths;
|
// 1. Set url’s host to base’s host.
|
||||||
url->m_paths.remove(url->m_paths.size() - 1);
|
url->m_paths = base_url->m_paths;
|
||||||
|
url->m_paths.remove(url->m_paths.size() - 1);
|
||||||
|
|
||||||
// 2. If the code point substring from pointer to the end of input does not start with a Windows drive letter and base’s path[0] is a normalized Windows drive letter, then append base’s path[0] to url’s path.
|
// 2. If the code point substring from pointer to the end of input does not start with a Windows drive letter and base’s path[0] is a normalized Windows drive letter, then append base’s path[0] to url’s path.
|
||||||
auto substring_from_pointer = input.substring_view(iterator - input.begin()).as_string();
|
auto substring_from_pointer = input.substring_view(iterator - input.begin()).as_string();
|
||||||
if (!starts_with_windows_drive_letter(substring_from_pointer) && is_normalized_windows_drive_letter(base_url->m_paths[0]))
|
if (!starts_with_windows_drive_letter(substring_from_pointer) && is_normalized_windows_drive_letter(base_url->m_paths[0]))
|
||||||
url->append_path(base_url->m_paths[0], URL::ApplyPercentEncoding::No);
|
url->append_path(base_url->m_paths[0], URL::ApplyPercentEncoding::No);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: This should be done outside of this file block, see below.
|
// 2. Set state to path state, and decrease pointer by 1.
|
||||||
state = State::Path;
|
state = State::Path;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// FIXME: 2. Set state to path state, and decrease pointer by 1.
|
|
||||||
break;
|
break;
|
||||||
// -> file host state, https://url.spec.whatwg.org/#file-host-state
|
// -> file host state, https://url.spec.whatwg.org/#file-host-state
|
||||||
case State::FileHost:
|
case State::FileHost:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue