Skip to content

Commit 10ff94e

Browse files
authored
Verify that HTTP header fields are not empty. (#258)
* Verify that HTTP header fields are not empty. * Add test for empty header token.
1 parent 8acaf3c commit 10ff94e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/llhttp/http.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ export class HTTP {
542542
}).otherwise(this.headersCompleted()),
543543
}, onInvalidHeaderFieldChar),
544544
)
545+
.peek(':', p.error(ERROR.INVALID_HEADER_TOKEN, 'Invalid header token'))
545546
.otherwise(span.headerField.start(n('header_field')));
546547

547548
n('header_field')

test/request/invalid.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,27 @@ off=14 version complete
307307
off=19 error code=10 reason="Invalid header token"
308308
```
309309

310+
### Invalid header token #3
311+
312+
<!-- meta={"type": "request", "noScan": true} -->
313+
```http
314+
GET / HTTP/1.1
315+
: Bar
316+
317+
318+
```
319+
320+
```log
321+
off=0 message begin
322+
off=0 len=3 span[method]="GET"
323+
off=3 method complete
324+
off=4 len=1 span[url]="/"
325+
off=6 url complete
326+
off=11 len=3 span[version]="1.1"
327+
off=14 version complete
328+
off=16 error code=10 reason="Invalid header token"
329+
```
330+
310331
### Invalid method
311332

312333
<!-- meta={"type": "request"} -->

0 commit comments

Comments
 (0)