Allow leading zeros in port number.
This commit is contained in:
parent
50a8e66965
commit
4f00f445b7
@ -69,7 +69,11 @@ Result<HttpUrl> parse_url(Slice url, HttpUrl::Protocol default_protocol) {
|
||||
}
|
||||
Slice userinfo_host;
|
||||
if (colon > userinfo_host_port.begin() && *colon == ':') {
|
||||
auto r_port = to_integer_safe<int>(Slice(colon + 1, userinfo_host_port.end()));
|
||||
Slice port_slice(colon + 1, userinfo_host_port.end());
|
||||
while (port_slice.size() > 1 && port_slice[0] == '0') {
|
||||
port_slice.remove_prefix(1);
|
||||
}
|
||||
auto r_port = to_integer_safe<int>(port_slice);
|
||||
if (r_port.is_error() || r_port.ok() == 0) {
|
||||
port = -1;
|
||||
} else {
|
||||
|
@ -52,6 +52,9 @@ TEST(Link, check_link) {
|
||||
check_link("tOn://google", "ton://google/");
|
||||
check_link("httP://google.com?1#tes", "http://google.com/?1#tes");
|
||||
check_link("httPs://google.com/?1#tes", "https://google.com/?1#tes");
|
||||
check_link("http://google.com:0", "");
|
||||
check_link("http://google.com:0000000001", "http://google.com:1/");
|
||||
check_link("http://google.com:-1", "");
|
||||
check_link("tg://google?1#tes", "tg://google?1#tes");
|
||||
check_link("tg://google/?1#tes", "tg://google?1#tes");
|
||||
check_link("TG:_", "tg://_/");
|
||||
|
Loading…
Reference in New Issue
Block a user