From: William A. Rowe Jr Date: Fri, 29 Jul 2016 15:49:02 +0000 (+0000) Subject: Introduce T_HTTP_CTRLS for efficiently finding non-text chars X-Git-Tag: 2.5.0-alpha~1362 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d627f5d16a9d417fb6cdd9e47abab4f93d93ef26;p=thirdparty%2Fapache%2Fhttpd.git Introduce T_HTTP_CTRLS for efficiently finding non-text chars git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1754540 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/gen_test_char.c b/server/gen_test_char.c index cf7b0f83b60..84df3d409f5 100644 --- a/server/gen_test_char.c +++ b/server/gen_test_char.c @@ -52,6 +52,7 @@ #define T_ESCAPE_LOGITEM (0x10) #define T_ESCAPE_FORENSIC (0x20) #define T_ESCAPE_URLENCODED (0x40) +#define T_HTTP_CTRLS (0x80) int main(int argc, char *argv[]) { @@ -67,6 +68,7 @@ int main(int argc, char *argv[]) "#define T_ESCAPE_LOGITEM (%u)\n" "#define T_ESCAPE_FORENSIC (%u)\n" "#define T_ESCAPE_URLENCODED (%u)\n" + "#define T_HTTP_CTRLS (%u)\n" "\n" "static const unsigned char test_char_table[256] = {", T_ESCAPE_SHELL_CMD, @@ -75,7 +77,8 @@ int main(int argc, char *argv[]) T_HTTP_TOKEN_STOP, T_ESCAPE_LOGITEM, T_ESCAPE_FORENSIC, - T_ESCAPE_URLENCODED); + T_ESCAPE_URLENCODED, + T_HTTP_CTRLS); for (c = 0; c < 256; ++c) { flags = 0; @@ -125,6 +128,14 @@ int main(int argc, char *argv[]) flags |= T_HTTP_TOKEN_STOP; } + /* Catch CTRLs other than VCHAR, HT and SP, and obs-text (RFC7230 3.2) + * This includes only the C0 plane, not C1 (which is obs-text itself.) + * XXX: Need to confirm this behavior on EBCDIC architecture + */ + if (!c || (apr_iscntrl(c) && c != '\t' && apr_isascii(c))) { + flags |= T_HTTP_CTRLS; + } + /* For logging, escape all control characters, * double quotes (because they delimit the request in the log file) * backslashes (because we use backslash for escaping)