Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue 716 #717

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ada/url-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ ada_really_inline size_t url::parse_port(std::string_view view,
ada_log("parse_port('", view, "') ", view.size());
uint16_t parsed_port{};
auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
if (r.ec == std::errc::result_out_of_range) {
if (r.ec != std::errc()) {
ada_log("parse_port: std::errc::result_out_of_range");
lemire marked this conversation as resolved.
Show resolved Hide resolved
is_valid = false;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion include/ada/url_aggregator-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ ada_really_inline size_t url_aggregator::parse_port(
ada_log("url_aggregator::parse_port('", view, "') ", view.size());
uint16_t parsed_port{};
auto r = std::from_chars(view.data(), view.data() + view.size(), parsed_port);
if (r.ec == std::errc::result_out_of_range) {
if (r.ec != std::errc()) {
ada_log("parse_port: std::errc::result_out_of_range");
is_valid = false;
return 0;
Expand Down
6 changes: 6 additions & 0 deletions tests/basic_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,10 @@ TYPED_TEST(basic_tests, path_setter_bug) {
ASSERT_TRUE(base_url->set_pathname("//.."));
ASSERT_TRUE(base_url->validate());
SUCCEED();
}

TYPED_TEST(basic_tests, negativeport) {
auto url = ada::parse<TypeParam>("https://www.google.com");
ASSERT_FALSE(url->set_port("-1"));
SUCCEED();
}
Loading