Skip to content

Commit

Permalink
fix permissive parsing setting
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Meily <[email protected]>
  • Loading branch information
ameily committed Mar 25, 2022
1 parent 87ce705 commit 1c6e8c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
19 changes: 10 additions & 9 deletions bazel/external/http_parser/http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,10 @@ enum http_host_state
(c) == '$' || (c) == ',')

#define STRICT_TOKEN(c) ((c == ' ') ? 0 : tokens[(unsigned char)c])
#define IS_URL_CHAR(c) (BIT_AT(normal_url_char, (unsigned char)c))
#define IS_HOST_CHAR(c) (IS_ALPHANUM(c) || (c) == '.' || (c) == '-')
#define TOKEN(c, permissive) ((c == ' ' && !permissive) ? 0 : tokens[(unsigned char)c])
#define IS_URL_CHAR(c, permissive) (BIT_AT(normal_url_char, (unsigned char)c) || \
(permissive && (((c) & 0x80) || ((c) == '\t') || ((c) == 0x0c))))
#define IS_HOST_CHAR(c, permissive) (IS_ALPHANUM(c) || (c) == '.' || (c) == '-' || (permissive && (c) == '_'))
#define TOKEN(c, permissive) (((c) == ' ' && !permissive) ? 0 : tokens[(unsigned char)c])

/**
* Verify that a char is a valid visible (printable) US-ASCII
Expand Down Expand Up @@ -550,7 +551,7 @@ parse_url_char(enum state s, const char ch, int permissive)
break;

case s_req_path:
if (IS_URL_CHAR(ch) || (permissive && (ch & 0x80))) {
if (IS_URL_CHAR(ch, permissive)) {
return s;
}

Expand All @@ -566,7 +567,7 @@ parse_url_char(enum state s, const char ch, int permissive)

case s_req_query_string_start:
case s_req_query_string:
if (IS_URL_CHAR(ch)) {
if (IS_URL_CHAR(ch, permissive)) {
return s_req_query_string;
}

Expand All @@ -582,7 +583,7 @@ parse_url_char(enum state s, const char ch, int permissive)
break;

case s_req_fragment_start:
if (IS_URL_CHAR(ch)) {
if (IS_URL_CHAR(ch, permissive)) {
return s_req_fragment;
}

Expand All @@ -597,7 +598,7 @@ parse_url_char(enum state s, const char ch, int permissive)
break;

case s_req_fragment:
if (IS_URL_CHAR(ch)) {
if (IS_URL_CHAR(ch, permissive)) {
return s;
}

Expand Down Expand Up @@ -2250,14 +2251,14 @@ http_parse_host_char(enum http_host_state s, const char ch, int permissive) {
return s_http_host_v6_start;
}

if (IS_HOST_CHAR(ch) || (permissive && (ch == '_'))) {
if (IS_HOST_CHAR(ch, permissive)) {
return s_http_host;
}

break;

case s_http_host:
if (IS_HOST_CHAR(ch) || (permissive && (ch == '_'))) {
if (IS_HOST_CHAR(ch, permissive)) {
return s_http_host;
}

Expand Down
6 changes: 3 additions & 3 deletions bazel/external/http_parser/http_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ typedef int (*http_cb)(http_parser*);
XX(200, OK, OK) \
XX(201, CREATED, Created) \
XX(202, ACCEPTED, Accepted) \
XX(203, NON_AUTHORITATIVE_INFORMATION, Non - Authoritative Information) \
XX(203, NON_AUTHORITATIVE_INFORMATION, Non-Authoritative Information) \
XX(204, NO_CONTENT, No Content) \
XX(205, RESET_CONTENT, Reset Content) \
XX(206, PARTIAL_CONTENT, Partial Content) \
XX(207, MULTI_STATUS, Multi - Status) \
XX(207, MULTI_STATUS, Multi-Status) \
XX(208, ALREADY_REPORTED, Already Reported) \
XX(226, IM_USED, IM Used) \
XX(300, MULTIPLE_CHOICES, Multiple Choices) \
Expand Down Expand Up @@ -181,7 +181,7 @@ enum http_status {
XX(22, CHECKOUT, CHECKOUT) \
XX(23, MERGE, MERGE) \
/* upnp */ \
XX(24, MSEARCH, M - SEARCH) \
XX(24, MSEARCH, M-SEARCH) \
XX(25, NOTIFY, NOTIFY) \
XX(26, SUBSCRIBE, SUBSCRIBE) \
XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
Expand Down

0 comments on commit 1c6e8c9

Please sign in to comment.