Skip to content

Commit 7238f4b

Browse files
committed
fix: check and eliminate non ascii on port setter
1 parent 84aab08 commit 7238f4b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/url-setters.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ namespace ada {
3030
if (trimmed.empty()) { port = std::nullopt; return true; }
3131
// Input should not start with control characters.
3232
if (ada::unicode::is_c0_control_or_space(trimmed.front())) { return false; }
33-
// Input should start with ascii digit character.
34-
if (!checkers::is_digit(input.front())) { return false; }
33+
// Input should contain at least one ascii digit.
34+
if (input.find_first_of("0123456789") == std::string_view::npos) { return false; }
3535

3636
// Revert changes if parse_port fails.
3737
std::optional<uint16_t> previous_port = port;

tests/wpt/ada_extra_setters_tests.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@
3737
"port": ""
3838
}
3939
},
40+
{
41+
"comment": "Leading u0009 on special scheme",
42+
"href": "https://yagiz.co:443",
43+
"new_value": "\u00098080",
44+
"expected": {
45+
"port": "8080"
46+
}
47+
},
48+
{
49+
"comment": "Leading u0009 on non-special scheme",
50+
"href": "wpt++://yagiz.co:443",
51+
"new_value": "\u00098080",
52+
"expected": {
53+
"port": "8080"
54+
}
55+
},
4056
{
4157
"comment": "Trailing control characters",
4258
"href": "https://yagiz.co:443",

0 commit comments

Comments
 (0)