diff --git a/include/ada/character_sets-inl.h b/include/ada/character_sets-inl.h index 0da407e1b..32b5c3aa4 100644 --- a/include/ada/character_sets-inl.h +++ b/include/ada/character_sets-inl.h @@ -462,15 +462,15 @@ constexpr uint8_t WWW_FORM_URLENCODED_PERCENT_ENCODE[32] = { // 30 31 32 33 34 35 36 37 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00, // 38 39 3A 3B 3C 3D 3E 3F - 0x00 | 0x00 | 0x00 | 0x00 | 0x10 | 0x00 | 0x40 | 0x80, + 0x00 | 0x00 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80, // 40 41 42 43 44 45 46 47 - 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00, + 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00, // 48 49 4A 4B 4C 4D 4E 4F 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00, // 50 51 52 53 54 55 56 57 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00, // 58 59 5A 5B 5C 5D 5E 5F - 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00, + 0x00 | 0x00 | 0x00 | 0x08 | 0x00 | 0x20 | 0x40 | 0x00, // 60 61 62 63 64 65 66 67 0x01 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00, // 68 69 6A 6B 6C 6D 6E 6F @@ -478,7 +478,7 @@ constexpr uint8_t WWW_FORM_URLENCODED_PERCENT_ENCODE[32] = { // 70 71 72 73 74 75 76 77 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00, // 78 79 7A 7B 7C 7D 7E 7F - 0x00 | 0x00 | 0x00 | 0x08 | 0x00 | 0x20 | 0x40 | 0x80, + 0x00 | 0x00 | 0x00 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80, // 80 81 82 83 84 85 86 87 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80, // 88 89 8A 8B 8C 8D 8E 8F diff --git a/tests/url_search_params.cpp b/tests/url_search_params.cpp index 2aee98d5e..df0b7b069 100644 --- a/tests/url_search_params.cpp +++ b/tests/url_search_params.cpp @@ -232,3 +232,25 @@ TEST(url_search_params, test_to_string_encoding) { "q1=foo&q2=foo+bar&q3=foo+bar&q4=foo%2Fbar"); SUCCEED(); } + +// https://github.com/cloudflare/workerd/issues/1777 +TEST(url_search_params, test_character_set) { + auto search_params = ada::url_search_params("key=value"); + + // - The application/x-www-form-urlencoded percent-encode set is the component + // percent-encode set and U+0021 (!), U+0027 (') to U+0029 RIGHT PARENTHESIS, + // inclusive, and U+007E (~). + // - The component percent-encode set is the userinfo percent-encode set and + // U+0024 ($) to U+0026 (&), inclusive, U+002B (+), and U+002C (,). + // - The userinfo percent-encode set is the path percent-encode set and U+002F + // (/), U+003A (:), U+003B (;), U+003D (=), U+0040 (@), U+005B ([) to U+005E + // (^), inclusive, and U+007C (|). + std::vector unique_keys = {'/', ':', ';', '=', '@', '[', ']', '^', '|', + '$', '&', '+', ',', '!', '\'', ')', '~'}; + for (auto& unique_key : unique_keys) { + auto value = "value" + std::string(1, unique_key); + search_params.set("key", value); + ASSERT_NE(search_params.to_string(), "key=" + value); + } + SUCCEED(); +}