mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +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
Notes:
sideshowbarker
2024-07-17 03:51:15 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/b76972ff32 Pull-request: https://github.com/SerenityOS/serenity/pull/19787
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;
|
||||
}
|
||||
// 2. Otherwise:
|
||||
// 1. If base is non-null and base’s scheme is "file", then:
|
||||
else if (base_url.has_value() && base_url->m_scheme == "file") {
|
||||
// 1. Set url’s host to base’s host.
|
||||
url->m_paths = base_url->m_paths;
|
||||
url->m_paths.remove(url->m_paths.size() - 1);
|
||||
else {
|
||||
// 1. If base is non-null and base’s scheme is "file", then:
|
||||
if (base_url.has_value() && base_url->m_scheme == "file") {
|
||||
// 1. Set url’s host to base’s host.
|
||||
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.
|
||||
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]))
|
||||
url->append_path(base_url->m_paths[0], URL::ApplyPercentEncoding::No);
|
||||
// 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();
|
||||
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);
|
||||
}
|
||||
|
||||
// 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;
|
||||
continue;
|
||||
}
|
||||
// FIXME: 2. Set state to path state, and decrease pointer by 1.
|
||||
break;
|
||||
// -> file host state, https://url.spec.whatwg.org/#file-host-state
|
||||
case State::FileHost:
|
||||
|
|
Loading…
Reference in a new issue