Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP parsing updates for RFC 9112 #155

Merged
merged 7 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Changes in release 0.34.0
* Interface changes:
- API and ABI backwards-compatible with 0.27.x and later
* New interfaces and features:
- ne_request.h: add ne_get_response_location()
- ne_redirect.h: support complete relative URI resolution
- ne_session.h: add NE_SESSFLAG_STRICT session flag
- HTTP strictness/compliance updated for RFC 9110/9112;
notably stricter in parsing header field line, chunked
transfer-encoding, status-line.
* Documentation & header updates for RFC 9110/9112.

Changes in release 0.33.0:
* Interface changes:
- API and ABI backwards-compatible with 0.27.x and later
Expand Down
8 changes: 8 additions & 0 deletions doc/ref/sessflags.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@
improve interoperability with SharePoint</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>NE_SESSFLAG_STRICT</constant> (default on)</term>
<listitem>
<simpara>disable this flag to parse HTTP/1.1 messages
without strict requirements introduced in RFC 7230 and
later</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

Expand Down
2 changes: 1 addition & 1 deletion macros/neon.m4
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ NE_VERSION_PATCH=0
NE_VERSION_TAG=-dev

# 0.33.x is backwards-compatible to 0.27.x, so AGE=6
NE_LIBTOOL_VERSINFO="33:${NE_VERSION_PATCH}:6"
NE_LIBTOOL_VERSINFO="34:${NE_VERSION_PATCH}:7"

NE_DEFINE_VERSIONS

Expand Down
29 changes: 29 additions & 0 deletions src/mktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,34 @@ static unsigned char gen_status_line(unsigned char ch)
return 99;
}

/* https://www.rfc-editor.org/rfc/rfc9110#name-tokens
token = 1*tchar

tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
/ "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
/ DIGIT / ALPHA
; any VCHAR, except delimiters

VCHAR = %x21-7E
delimiters = (DQUOTE and "(),/:;<=>?@[\]{}")
*/

static unsigned char gen_token(unsigned char ch)
{
switch (ch) {
case '!': case '#': case '$': case '%': case '&': case '\'': case '*':
case '+': case '-': case '.': case '^': case '_': case '`': case '|':
case '~':
return ch;
case '(': case ')': case ',': case '/': case ':': case ';': case '<':
case '=': case '>': case '?': case '@': case '[': case '\\': case ']':
case '{': case '}': case '"':
return 0;
default:
return ch >= 0x21 && ch <= 0x7E ? tolower(ch) : 0;
}
}

#define FLAG_DECIMAL (0x01)
#define FLAG_SHORT (0x02)

Expand All @@ -130,6 +158,7 @@ static const struct {
{ "status_line", gen_status_line, FLAG_DECIMAL | FLAG_SHORT },
{ "extparam", gen_extparam, FLAG_DECIMAL | FLAG_SHORT },
{ "safe_username", safe_username, FLAG_DECIMAL | FLAG_SHORT },
{ "http_token", gen_token, 0 },
};

static void fail(const char *err, const char *arg)
Expand Down
Loading