Skip to content

Accept tab as optional whitespace around ranges - #72

Closed
yxshee wants to merge 1 commit into
jshttp:masterfrom
yxshee:fix/htab-ows
Closed

yxshee wants to merge 1 commit into
jshttp:masterfrom
yxshee:fix/htab-ows

Conversation

@yxshee

@yxshee yxshee commented Nov 8, 2026

Copy link
Copy Markdown

The TypeScript rewrite skips only spaces (char code 32) around each range-spec. RFC 9110 lets a list element be surrounded by OWS, which is SP or HTAB, and 1.2.1 accepted tabs because it used trim().

On master a tab makes that range invalid, so it is dropped or the whole header becomes malformed:

parse(100, "bytes=0-1,\t2-3"); // { type: "bytes", ranges: [{ start: 0, end: 1 }] }, 2-3 is lost
parse(100, "bytes=\t0-1");     // -2 (1.2.1 returns [{ start: 0, end: 1 }])

jshttp/fresh made the same change in #77. This adds a small isOws check (SP or HTAB) to the two whitespace loops. Whitespace around the - itself is still rejected, since the grammar does not allow OWS there.

Testing: a new spec with tabs before, after and between ranges fails on master (returns -2) and passes with the fix. npm test (prettier, tsc, vitest with 100% coverage) passes.

The TypeScript rewrite only skips spaces around each range-spec, so a
tab (also OWS in RFC 9110) makes the range invalid. 1.2.1 used trim()
and accepted it.
@blakeembrey

Copy link
Copy Markdown
Member

Thanks, rolled into my existing work in #71.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants