Skip to content

Commit 5bc52ed

Browse files
committed
fix: port_rule has_number for port zero at end of input
1 parent b662a8f commit 5bc52ed

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

include/boost/url/rfc/detail/impl/port_rule.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ parse(
6868
}
6969
// no digits
7070
t.str = core::string_view(start, it);
71-
t.has_number = it != end;
71+
t.has_number = it != start;
7272
t.number = 0;
7373
return t;
7474
}

test/unit/rfc/authority_rule.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,27 @@ class authority_rule_test
6464
a.encoded_password(), "y");
6565
}
6666
}
67+
68+
// port zero at end of input
69+
// (has_number regression)
70+
{
71+
auto rv = grammar::parse(
72+
"host:0", authority_rule);
73+
if(BOOST_TEST(rv.has_value()))
74+
{
75+
BOOST_TEST(rv->has_port());
76+
BOOST_TEST_EQ(rv->port_number(), 0);
77+
}
78+
}
79+
{
80+
auto rv = grammar::parse(
81+
"host:000", authority_rule);
82+
if(BOOST_TEST(rv.has_value()))
83+
{
84+
BOOST_TEST(rv->has_port());
85+
BOOST_TEST_EQ(rv->port_number(), 0);
86+
}
87+
}
6788
}
6889
};
6990

0 commit comments

Comments
 (0)