Skip to content

Commit

Permalink
fix: handle brackets in query_chars
Browse files Browse the repository at this point in the history
Although 1317ca8 includes support for brackets in key_chars, the lack of support in query_chars made still led to errors when the the complete url is parsed at once.

fix #93
  • Loading branch information
alandefreitas committed Dec 15, 2023
1 parent 02c6984 commit b8b9140
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/boost/url/rfc/detail/charsets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ path_chars =
constexpr
auto
query_chars =
pchars + '/' + '?';
pchars + '/' + '?' + '[' + ']';

constexpr
auto
Expand Down
2 changes: 1 addition & 1 deletion test/unit/url_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ struct url_base_test
u.set_query("!@#$%^&*()_+=-;:'{}[]|\\?/>.<,");
BOOST_TEST(u.has_query());
BOOST_TEST(u.encoded_query() ==
"!@%23$%25%5E&*()_+=-;:'%7B%7D%5B%5D%7C%5C?/%3E.%3C,");
"!@%23$%25%5E&*()_+=-;:'%7B%7D[]%7C%5C?/%3E.%3C,");
BOOST_TEST_EQ(u.params().size(), 2u);
BOOST_TEST_EQ((*u.params().begin()).key, "!@#$%^");
BOOST_TEST_EQ((*u.params().begin()).value, "");
Expand Down
6 changes: 6 additions & 0 deletions test/unit/url_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,12 @@ class url_view_test
BOOST_TEST_EQ(u.encoded_query(), "k=");
BOOST_TEST_EQ(u.query(), "k=");
}
{
url_view u("http://?k[]=");
BOOST_TEST(u.has_query());
BOOST_TEST_EQ(u.encoded_query(), "k[]=");
BOOST_TEST_EQ(u.query(), "k[]=");
}
{
url_view u("http://?#");
BOOST_TEST(u.has_query());
Expand Down

0 comments on commit b8b9140

Please sign in to comment.