Skip to content

Commit

Permalink
Fix: set_port should return false if input does not start with a digit
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisev committed Dec 11, 2024
1 parent 1450038 commit de66c68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/upa/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -1982,10 +1982,11 @@ inline validation_errc url_parser::url_parse(url_serializer& urls, const CharT*
urls.clear_part(url::PORT);
}
}
}
// 2.2. If state override is given, then return
if (state_override)
return validation_errc::ok;
// 2.2. If state override is given, then return
if (state_override)
return validation_errc::ok;
} else if (state_override)
return validation_errc::ignored;
state = path_start_state;
pointer = end_of_digits;
} else {
Expand Down
4 changes: 4 additions & 0 deletions test/test-url-setters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ TEST_CASE("Test setters with special URL's") {
CHECK_EQ(url.host(), "example.net:88");
CHECK_EQ(url.port_int(), 88);

CHECK(url.port("90="));
CHECK_FALSE(url.port("abc"));
CHECK_EQ(url.port_int(), 90);

CHECK(url.port(""));
CHECK_EQ(url.host(), "example.net");

Expand Down

0 comments on commit de66c68

Please sign in to comment.