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

test: validate missing encoding in to_string #606

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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/character_sets-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ constexpr uint8_t WWW_FORM_URLENCODED_PERCENT_ENCODE[32] = {
// 20 21 22 23 24 25 26 27
0x00 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
// 28 29 2A 2B 2C 2D 2E 2F
0x01 | 0x02 | 0x00 | 0x08 | 0x10 | 0x00 | 0x00 | 0x00,
0x01 | 0x02 | 0x00 | 0x08 | 0x10 | 0x00 | 0x00 | 0x80,
// 30 31 32 33 34 35 36 37
0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
// 38 39 3A 3B 3C 3D 3E 3F
Expand Down
13 changes: 13 additions & 0 deletions tests/url_search_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,16 @@ TEST(url_search_params, iterators) {

SUCCEED();
}

// https://github.com/cloudflare/workerd/issues/1777
TEST(url_search_params, test_to_string_encoding) {
auto search_params =
ada::url_search_params("q1=foo&q2=foo+bar&q3=foo bar&q4=foo/bar");
ASSERT_EQ(search_params.get("q1").value(), "foo");
ASSERT_EQ(search_params.get("q2").value(), "foo bar");
ASSERT_EQ(search_params.get("q3").value(), "foo bar");
ASSERT_EQ(search_params.get("q4").value(), "foo/bar");
ASSERT_EQ(search_params.to_string(),
"q1=foo&q2=foo+bar&q3=foo+bar&q4=foo%2Fbar");
SUCCEED();
}
Loading