mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-21 01:40:46 +00:00
AK: Strip leading/trailing C0-control-or-space in URLs correctly
We have to stop scanning once we hit a non-strippable character. Add some tests to cover this.
This commit is contained in:
parent
468bb54677
commit
c0d1a75881
Notes:
sideshowbarker
2024-07-18 17:03:05 +09:00
Author: https://github.com/awesomekling
Commit: c0d1a75881
2 changed files with 27 additions and 2 deletions
|
@ -196,12 +196,16 @@ URL URLParser::parse(Badge<URL>, const StringView& raw_input, URL const* base_ur
|
|||
if (raw_input[i] <= 0x20) {
|
||||
++start_index;
|
||||
has_validation_error = true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < raw_input.length(); ++i) {
|
||||
if (raw_input[raw_input.length() - 1 - i] <= 0x20) {
|
||||
for (ssize_t i = raw_input.length() - 1; i >= 0; --i) {
|
||||
if (raw_input[i] <= 0x20) {
|
||||
--end_index;
|
||||
has_validation_error = true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (has_validation_error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue