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

Verify that HTTP header fields are not empty. #258

Merged
merged 2 commits into from
Oct 27, 2023
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
1 change: 1 addition & 0 deletions src/llhttp/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ export class HTTP {
}).otherwise(this.headersCompleted()),
}, onInvalidHeaderFieldChar),
)
.peek(':', p.error(ERROR.INVALID_HEADER_TOKEN, 'Invalid header token'))
.otherwise(span.headerField.start(n('header_field')));

n('header_field')
Expand Down
21 changes: 21 additions & 0 deletions test/request/invalid.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,27 @@ off=14 version complete
off=19 error code=10 reason="Invalid header token"
```

### Invalid header token #3

<!-- meta={"type": "request", "noScan": true} -->
```http
GET / HTTP/1.1
: Bar
```

```log
off=0 message begin
off=0 len=3 span[method]="GET"
off=3 method complete
off=4 len=1 span[url]="/"
off=6 url complete
off=11 len=3 span[version]="1.1"
off=14 version complete
off=16 error code=10 reason="Invalid header token"
```

### Invalid method

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