diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-25 04:41:26 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-25 04:41:26 +0000 |
commit | 7b31d4f4901cdb89a79f2f7de4a6b8bb637b523b (patch) | |
tree | fdeb0b5ff80273f95ce61607fc3613dff0b9a235 /server/gen_test_char.c | |
parent | Adding upstream version 2.4.38. (diff) | |
download | apache2-7b31d4f4901cdb89a79f2f7de4a6b8bb637b523b.tar.xz apache2-7b31d4f4901cdb89a79f2f7de4a6b8bb637b523b.zip |
Adding upstream version 2.4.59.upstream/2.4.59upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'server/gen_test_char.c')
-rw-r--r-- | server/gen_test_char.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/server/gen_test_char.c b/server/gen_test_char.c index 48ae6f4..248216b 100644 --- a/server/gen_test_char.c +++ b/server/gen_test_char.c @@ -54,6 +54,7 @@ #define T_ESCAPE_URLENCODED (0x40) #define T_HTTP_CTRLS (0x80) #define T_VCHAR_OBSTEXT (0x100) +#define T_URI_UNRESERVED (0x200) int main(int argc, char *argv[]) { @@ -71,6 +72,7 @@ int main(int argc, char *argv[]) "#define T_ESCAPE_URLENCODED (%u)\n" "#define T_HTTP_CTRLS (%u)\n" "#define T_VCHAR_OBSTEXT (%u)\n" + "#define T_URI_UNRESERVED (%u)\n" "\n" "static const unsigned short test_char_table[256] = {", T_ESCAPE_SHELL_CMD, @@ -81,7 +83,9 @@ int main(int argc, char *argv[]) T_ESCAPE_FORENSIC, T_ESCAPE_URLENCODED, T_HTTP_CTRLS, - T_VCHAR_OBSTEXT); + T_VCHAR_OBSTEXT, + T_URI_UNRESERVED + ); for (c = 0; c < 256; ++c) { flags = 0; @@ -123,7 +127,7 @@ int main(int argc, char *argv[]) /* Stop for any non-'token' character, including ctrls, obs-text, * and "tspecials" (RFC2068) a.k.a. "separators" (RFC2616), which - * is easer to express as characters remaining in the ASCII token set + * is easier to express as characters remaining in the ASCII token set */ if (!c || !(apr_isalnum(c) || strchr("!#$%&'*+-.^_`|~", c))) { flags |= T_HTTP_TOKEN_STOP; @@ -164,10 +168,25 @@ int main(int argc, char *argv[]) flags |= T_ESCAPE_FORENSIC; } + /* Characters in the RFC 3986 "unreserved" set. + * https://datatracker.ietf.org/doc/html/rfc3986#section-2.3 */ + if (c && (apr_isalnum(c) || strchr("-._~", c))) { + flags |= T_URI_UNRESERVED; + } + printf("0x%03x%c", flags, (c < 255) ? ',' : ' '); } - printf("\n};\n"); + printf("\n};\n\n"); + + printf( + "/* we assume the folks using this ensure 0 <= c < 256... which means\n" + " * you need a cast to (unsigned char) first, you can't just plug a\n" + " * char in here and get it to work, because if char is signed then it\n" + " * will first be sign extended.\n" + " */\n" + "#define TEST_CHAR(c, f) (test_char_table[(unsigned char)(c)] & (f))\n" + ); return 0; } |