From 2839784927c82410e5a618bce0c540254cf66ce0 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 24 May 2011 09:07:09 -0700 Subject: [PATCH] HTTP_STRICT ifdefs out behavior introduced in 50b9bec Fixes #37. --- Makefile | 5 +++-- http_parser.c | 7 ++++++- http_parser.h | 2 -- test.c | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2b945c1..5608528 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ -OPT_DEBUG=-O0 -g -Wall -Wextra -Werror -I. -OPT_FAST=-O3 -DHTTP_PARSER_STRICT=0 -I. +CPPFLAGS?=-DHTTP_PARSER_STRICT=1 +OPT_DEBUG=-O0 -g -Wall -Wextra -Werror -I. $(CPPFLAGS) +OPT_FAST=-O3 -DHTTP_PARSER_STRICT=0 -I. $(CPPFLAGS) CC?=gcc diff --git a/http_parser.c b/http_parser.c index 1c30c1d..01de95f 100644 --- a/http_parser.c +++ b/http_parser.c @@ -191,6 +191,9 @@ static const uint8_t normal_url_char[256] = { /* 120 x 121 y 122 z 123 { 124 | 125 } 126 ~ 127 del */ 1, 1, 1, 1, 1, 1, 1, 0, +#if HTTP_PARSER_STRICT + 0 +#else /* Remainder of non-ASCII range are accepted as-is to support implicitly UTF-8 encoded paths. This is out of spec, but clients generate this and most other HTTP servers support it. We should, too. */ @@ -210,7 +213,9 @@ static const uint8_t normal_url_char[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1 }; + 1, 1, 1, 1, 1, 1, 1, 1 +#endif +}; /* normal_url_char */ enum state diff --git a/http_parser.h b/http_parser.h index afce3e9..b30a74f 100644 --- a/http_parser.h +++ b/http_parser.h @@ -49,8 +49,6 @@ typedef int ssize_t; */ #ifndef HTTP_PARSER_STRICT # define HTTP_PARSER_STRICT 1 -#else -# define HTTP_PARSER_STRICT 0 #endif diff --git a/test.c b/test.c index 4a93163..3b35395 100644 --- a/test.c +++ b/test.c @@ -582,6 +582,7 @@ const struct message requests[] = ,.body= "" } +#if !HTTP_PARSER_STRICT #define UTF8_PATH_REQ 21 , {.name= "utf-8 path request" ,.type= HTTP_REQUEST @@ -602,6 +603,7 @@ const struct message requests[] = } ,.body= "" } +#endif /* !HTTP_PARSER_STRICT */ #define QUERY_TERMINATED_HOST 22 , {.name= "host terminated by a query string"