bug: header value checks are too strict in fetch
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 880
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 68
Description
Bug Description
The regex here is too strict for fetch which causes a bunch of tests to fail:
{ fail: '\x01' }
{ fail: '\x02' }
{ fail: '\x03' }
{ fail: '\x04' }
{ fail: '\x05' }
{ fail: '\x06' }
{ fail: '\x07' }
{ fail: '\b' }
{ fail: '\x0E' }
{ fail: '\x0F' }
{ fail: '\x10' }
{ fail: '\x11' }
{ fail: '\x12' }
{ fail: '\x13' }
{ fail: '\x14' }
{ fail: '\x15' }
{ fail: '\x16' }
{ fail: '\x17' }
{ fail: '\x18' }
{ fail: '\x19' }
{ fail: '\x1A' }
{ fail: '\x1B' }
{ fail: '\x1C' }
{ fail: '\x1D' }
{ fail: '\x1E' }
{ fail: '\x1F' }
Reproducible By
https://gist.github.com/KhafraDev/cc178abba0a89580008f44c7ebee76a3
Sorry for the messy code it was taken almost directly from wpt (https://github.com/web-platform-tests/wpt/blob/master/fetch/api/headers/header-values-normalize.any.js)
Expected Behavior
The tests should pass.
Logs & Screenshots
Environment
Additional context
These checks were added in a29a151d to fix an issue where headers weren't being sanitized.
cc @mcollina
According to the spec, a header value is a string (or Uint8Array, etc) that has no leading or trailing whitespace and doesn't contain \0 or LF or CR.
Also see https://github.com/httpwg/http-core/issues/19#issuecomment-271903665
and the spec
The definition of header value is not defined in terms of an HTTP token production as it is broken
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read lib/core/request.js at line 26 and compare its header-value check with the linked Fetch and WPT expectations. Reproduce the listed failing cases from the gist or relevant WPT test, then verify that the affected tests pass while NUL, LF, and CR remain rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100