Skip to content

Commit ddb1950

Browse files
committed
release: 9.1.0
1 parent f8aeb35 commit ddb1950

File tree

6 files changed

+1238
-760
lines changed

6 files changed

+1238
-760
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.5.1)
22
cmake_policy(SET CMP0069 NEW)
33

4-
project(llhttp VERSION 9.0.1)
4+
project(llhttp VERSION 9.1.0)
55
include(GNUInstallDirs)
66

77
set(CMAKE_C_STANDARD 99)

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,14 @@ Normally `llhttp` would error when a CR is not followed by LF when terminating t
361361
request line, the status line, the headers or a chunk header.
362362
With this flag only a CR is required to terminate such sections.
363363
364+
### `void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled)`
365+
366+
Enables/disables lenient handling of line separators.
367+
368+
Normally `llhttp` would error when a LF is not preceded by CR when terminating the
369+
request line, the status line, the headers, a chunk header or a chunk data.
370+
With this flag only a LF is required to terminate such sections.
371+
364372
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
365373
366374
### `void llhttp_set_lenient_optional_crlf_after_chunk(llhttp_t* parser, int enabled)`
@@ -373,6 +381,15 @@ With this flag the new chunk can start immediately after the previous one.
373381
374382
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
375383
384+
### `void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled)`
385+
386+
Enables/disables lenient handling of spaces after chunk size.
387+
388+
Normally `llhttp` would error when after a chunk size is followed by one or more spaces are present instead of a CRLF or `;`.
389+
With this flag this check is disabled.
390+
391+
**Enabling this flag can pose a security issue since you will be exposed to request smuggling attacks. USE WITH CAUTION!**
392+
376393
## Build Instructions
377394
378395
Make sure you have [Node.js](https://nodejs.org/), npm and npx installed. Then under project directory run:

include/llhttp.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#define INCLUDE_LLHTTP_H_
44

55
#define LLHTTP_VERSION_MAJOR 9
6-
#define LLHTTP_VERSION_MINOR 0
7-
#define LLHTTP_VERSION_PATCH 1
6+
#define LLHTTP_VERSION_MINOR 1
7+
#define LLHTTP_VERSION_PATCH 0
88

99
#ifndef INCLUDE_LLHTTP_ITSELF_H_
1010
#define INCLUDE_LLHTTP_ITSELF_H_
@@ -30,7 +30,7 @@ struct llhttp__internal_s {
3030
uint8_t http_major;
3131
uint8_t http_minor;
3232
uint8_t header_state;
33-
uint8_t lenient_flags;
33+
uint16_t lenient_flags;
3434
uint8_t upgrade;
3535
uint8_t finish;
3636
uint16_t flags;
@@ -115,7 +115,9 @@ enum llhttp_lenient_flags {
115115
LENIENT_VERSION = 0x10,
116116
LENIENT_DATA_AFTER_CLOSE = 0x20,
117117
LENIENT_OPTIONAL_LF_AFTER_CR = 0x40,
118-
LENIENT_OPTIONAL_CRLF_AFTER_CHUNK = 0x80
118+
LENIENT_OPTIONAL_CRLF_AFTER_CHUNK = 0x80,
119+
LENIENT_OPTIONAL_CR_BEFORE_LF = 0x100,
120+
LENIENT_SPACES_AFTER_CHUNK_SIZE = 0x200
119121
};
120122
typedef enum llhttp_lenient_flags llhttp_lenient_flags_t;
121123

src/api.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,22 @@ void llhttp_set_lenient_optional_crlf_after_chunk(llhttp_t* parser, int enabled)
315315
}
316316
}
317317

318+
void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled) {
319+
if (enabled) {
320+
parser->lenient_flags |= LENIENT_OPTIONAL_CR_BEFORE_LF;
321+
} else {
322+
parser->lenient_flags &= ~LENIENT_OPTIONAL_CR_BEFORE_LF;
323+
}
324+
}
325+
326+
void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled) {
327+
if (enabled) {
328+
parser->lenient_flags |= LENIENT_SPACES_AFTER_CHUNK_SIZE;
329+
} else {
330+
parser->lenient_flags &= ~LENIENT_SPACES_AFTER_CHUNK_SIZE;
331+
}
332+
}
333+
318334
/* Callbacks */
319335

320336

src/http.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,26 @@ int llhttp__after_headers_complete(llhttp_t* parser, const char* p,
3939
int hasBody;
4040

4141
hasBody = parser->flags & F_CHUNKED || parser->content_length > 0;
42-
if (parser->upgrade && (parser->method == HTTP_CONNECT ||
43-
(parser->flags & F_SKIPBODY) || !hasBody)) {
42+
if (
43+
(parser->upgrade && (parser->method == HTTP_CONNECT ||
44+
(parser->flags & F_SKIPBODY) || !hasBody)) ||
45+
/* See RFC 2616 section 4.4 - 1xx e.g. Continue */
46+
(parser->type == HTTP_RESPONSE && parser->status_code / 100 == 1)
47+
) {
4448
/* Exit, the rest of the message is in a different protocol. */
4549
return 1;
4650
}
4751

48-
if (parser->flags & F_SKIPBODY) {
52+
/* See RFC 2616 section 4.4 */
53+
if (
54+
parser->flags & F_SKIPBODY || /* response to a HEAD request */
55+
(
56+
parser->type == HTTP_RESPONSE && (
57+
parser->status_code == 204 || /* No Content */
58+
parser->status_code == 304 /* Not Modified */
59+
)
60+
)
61+
) {
4962
return 0;
5063
} else if (parser->flags & F_CHUNKED) {
5164
/* chunked encoding - ignore Content-Length header, prepare for a chunk */

0 commit comments

Comments
 (0)