]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Improved display of invalid characters in parse error messages.
authorStephan Bosch <stephan@rename-it.nl>
Sun, 15 Sep 2013 00:46:25 +0000 (03:46 +0300)
committerStephan Bosch <stephan@rename-it.nl>
Sun, 15 Sep 2013 00:46:25 +0000 (03:46 +0300)
src/lib-http/http-request-parser.c
src/lib-http/http-response-parser.c

index a1a6b6fadf39fb87944c3cd01088f719768ebf18..3ca3f0cedbe58691e305b635152ba527582d27db 100644 (file)
@@ -96,8 +96,12 @@ static int http_request_parse_target(struct http_request_parser *parser)
 static inline const char *_chr_sanitize(unsigned char c)
 {
        if (c >= 0x20 && c < 0x7F)
-               return t_strdup_printf("'%c'", c);
-       return t_strdup_printf("0x%02x", c);
+               return t_strdup_printf("`%c'", c);
+       if (c == 0x0a)
+               return "<LF>";
+       if (c == 0x0d)
+               return "<CR>";
+       return t_strdup_printf("<0x%02x>", c);
 }
 
 static int http_request_parse(struct http_request_parser *parser,
index db0a37883999ea102cf7a9b3b5e3bd91c1936348..c79fb4d44cb4f27fad6f32e87476312cad2535c4 100644 (file)
@@ -94,8 +94,12 @@ static int http_response_parse_reason(struct http_response_parser *parser)
 static inline const char *_chr_sanitize(unsigned char c)
 {
        if (c >= 0x20 && c < 0x7F)
-               return t_strdup_printf("'%c'", c);
-       return t_strdup_printf("0x%02x", c);
+               return t_strdup_printf("`%c'", c);
+       if (c == 0x0a)
+               return "<LF>";
+       if (c == 0x0d)
+               return "<CR>";
+       return t_strdup_printf("<0x%02x>", c);
 }
 
 static int http_response_parse(struct http_response_parser *parser,