Skip to content

Commit a460fcd

Browse files
authored
test: validate missing encoding in to_string (#606)
* test: validate missing encoding in to_string * fix: update encoding set to represent reality * fix formatting
1 parent e2d21eb commit a460fcd

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

include/ada/character_sets-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ constexpr uint8_t WWW_FORM_URLENCODED_PERCENT_ENCODE[32] = {
458458
// 20 21 22 23 24 25 26 27
459459
0x00 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80,
460460
// 28 29 2A 2B 2C 2D 2E 2F
461-
0x01 | 0x02 | 0x00 | 0x08 | 0x10 | 0x00 | 0x00 | 0x00,
461+
0x01 | 0x02 | 0x00 | 0x08 | 0x10 | 0x00 | 0x00 | 0x80,
462462
// 30 31 32 33 34 35 36 37
463463
0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00,
464464
// 38 39 3A 3B 3C 3D 3E 3F

tests/url_search_params.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,16 @@ TEST(url_search_params, iterators) {
219219

220220
SUCCEED();
221221
}
222+
223+
// https://github.com/cloudflare/workerd/issues/1777
224+
TEST(url_search_params, test_to_string_encoding) {
225+
auto search_params =
226+
ada::url_search_params("q1=foo&q2=foo+bar&q3=foo bar&q4=foo/bar");
227+
ASSERT_EQ(search_params.get("q1").value(), "foo");
228+
ASSERT_EQ(search_params.get("q2").value(), "foo bar");
229+
ASSERT_EQ(search_params.get("q3").value(), "foo bar");
230+
ASSERT_EQ(search_params.get("q4").value(), "foo/bar");
231+
ASSERT_EQ(search_params.to_string(),
232+
"q1=foo&q2=foo+bar&q3=foo+bar&q4=foo%2Fbar");
233+
SUCCEED();
234+
}

0 commit comments

Comments
 (0)