Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
http: verify chunk parameters
  • Loading branch information
ronag authored and ShogunPanda committed Sep 1, 2022
commit c2ea408cd0f37eb973793e5a5e0ea9f5bcd8b262
5 changes: 3 additions & 2 deletions src/llhttp/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,11 @@ export class HTTP {
.otherwise(p.error(ERROR.INVALID_CHUNK_SIZE,
'Invalid character in chunk size'));

// just ignore this.
n('chunk_parameters')
.match('\r', n('chunk_size_almost_done'))
.skipTo(n('chunk_parameters'));
.match(HEADER_CHARS, n('chunk_parameters'))
.otherwise(p.error(ERROR.STRICT,
'Invalid character in chunk parameters'));

if (this.mode === 'strict') {
n('chunk_size_almost_done')
Expand Down
22 changes: 22 additions & 0 deletions test/request/transfer-encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,25 @@ off=52 len=3 span[body]="foo"
off=57 chunk complete
off=57 error code=12 reason="Invalid character in chunk size"
```

## Validate chunk parameters

<!-- meta={"type": "request", "mode": "strict"} -->
```http
PUT /url HTTP/1.1
Transfer-Encoding: chunked

3 \n \r\n\
foo


```

```log
off=0 message begin
off=4 len=4 span[url]="/url"
off=19 len=17 span[header_field]="Transfer-Encoding"
off=38 len=7 span[header_value]="chunked"
off=49 headers complete method=4 v=1/1 flags=208 content_length=0
off=51 error code=2 reason="Invalid character in chunk parameters"
```