mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-15 23:37:32 +03:00
AK: Check URL parser input for invalid (tabs or spaces) in 1 pass
Combine 2 passes into 1 by iterating over the input once and checking for both '\t' and '\n'.
This commit is contained in:
parent
7e2d9bfd53
commit
7ad7ae7000
Notes:
sideshowbarker
2024-07-16 18:06:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7ad7ae7000 Pull-request: https://github.com/SerenityOS/serenity/pull/22496 Reviewed-by: https://github.com/LucasChollet
@ -796,9 +796,12 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
|
||||
|
||||
// 2. If input contains any ASCII tab or newline, invalid-URL-unit validation error.
|
||||
// 3. Remove all ASCII tab or newline from input.
|
||||
if (processed_input.contains("\t"sv) || processed_input.contains("\n"sv)) {
|
||||
report_validation_error();
|
||||
processed_input = processed_input.replace("\t"sv, ""sv, ReplaceMode::All).replace("\n"sv, ""sv, ReplaceMode::All);
|
||||
for (auto const ch : processed_input) {
|
||||
if (ch == '\t' || ch == '\n') {
|
||||
report_validation_error();
|
||||
processed_input = processed_input.replace("\t"sv, ""sv, ReplaceMode::All).replace("\n"sv, ""sv, ReplaceMode::All);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Let state be state override if given, or scheme start state otherwise.
|
||||
|
Loading…
Reference in New Issue
Block a user