mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:57:45 +00:00
AK: Do not trim away non-ASCII bytes when parsing URL
Because non-ASCII code points have negative byte values, trimming away control characters requires checking for negative bytes values. This also adds a test case with a URL containing non-ASCII code points.
This commit is contained in:
parent
44937e2dfc
commit
99d5555134
2 changed files with 11 additions and 2 deletions
|
@ -174,7 +174,7 @@ URL URLParser::parse(Badge<URL>, StringView const& raw_input, URL const* base_ur
|
|||
size_t start_index = 0;
|
||||
size_t end_index = raw_input.length();
|
||||
for (size_t i = 0; i < raw_input.length(); ++i) {
|
||||
if (raw_input[i] <= 0x20) {
|
||||
if (0 <= raw_input[i] && raw_input[i] <= 0x20) {
|
||||
++start_index;
|
||||
has_validation_error = true;
|
||||
} else {
|
||||
|
@ -182,7 +182,7 @@ URL URLParser::parse(Badge<URL>, StringView const& raw_input, URL const* base_ur
|
|||
}
|
||||
}
|
||||
for (ssize_t i = raw_input.length() - 1; i >= 0; --i) {
|
||||
if (raw_input[i] <= 0x20) {
|
||||
if (0 <= raw_input[i] && raw_input[i] <= 0x20) {
|
||||
--end_index;
|
||||
has_validation_error = true;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue