@@ -19,10 +19,10 @@ namespace ada::checkers {
19
19
}
20
20
21
21
22
- // for use with path_signature
22
+ // for use with path_signature, we include all characters that need percent encoding.
23
23
static constexpr uint8_t path_signature_table[256 ] = {
24
24
1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
25
- 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 1 , 0 , 8 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 4 , 0 ,
25
+ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 1 , 1 , 0 , 8 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 4 , 0 ,
26
26
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
27
27
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 ,
28
28
1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
@@ -32,8 +32,28 @@ namespace ada::checkers {
32
32
1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
33
33
1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
34
34
1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 };
35
+ static_assert (path_signature_table[uint8_t (' ?' )] == 1 );
36
+ static_assert (path_signature_table[uint8_t (' `' )] == 1 );
37
+ static_assert (path_signature_table[uint8_t (' {' )] == 1 );
38
+ static_assert (path_signature_table[uint8_t (' }' )] == 1 );
39
+ //
40
+ static_assert (path_signature_table[uint8_t (' ' )] == 1 );
41
+ static_assert (path_signature_table[uint8_t (' ?' )] == 1 );
42
+ static_assert (path_signature_table[uint8_t (' "' )] == 1 );
43
+ static_assert (path_signature_table[uint8_t (' #' )] == 1 );
44
+ static_assert (path_signature_table[uint8_t (' <' )] == 1 );
45
+ static_assert (path_signature_table[uint8_t (' >' )] == 1 );
46
+ //
47
+ static_assert (path_signature_table[0 ] == 1 );
48
+ static_assert (path_signature_table[31 ] == 1 );
49
+ static_assert (path_signature_table[127 ] == 1 );
50
+ static_assert (path_signature_table[128 ] == 1 );
51
+ static_assert (path_signature_table[255 ] == 1 );
35
52
36
53
ada_really_inline constexpr uint8_t path_signature (std::string_view input) noexcept {
54
+ // The path percent-encode set is the query percent-encode set and U+003F (?), U+0060 (`), U+007B ({), and U+007D (}).
55
+ // The query percent-encode set is the C0 control percent-encode set and U+0020 SPACE, U+0022 ("), U+0023 (#), U+003C (<), and U+003E (>).
56
+ // The C0 control percent-encode set are the C0 controls and all code points greater than U+007E (~).
37
57
size_t i = 0 ;
38
58
uint8_t accumulator{};
39
59
for (; i + 7 < input.size (); i += 8 ) {
0 commit comments