Skip to content

fix: preserve header tokens with whitespace preceding commas in vary parser - #423

Open
TalhaHunter101 wants to merge 1 commit into
fastify:mainfrom
TalhaHunter101:fix/vary-header-ows
Open

TalhaHunter101 wants to merge 1 commit into
fastify:mainfrom
TalhaHunter101:fix/vary-header-ows

Conversation

@TalhaHunter101

Copy link
Copy Markdown

Fixes #422

Description

In vary.js, parse(header) advances pos = i + 1 when encountering whitespace. If whitespace occurs immediately before a comma (e.g. Origin , Accept-Encoding), pos becomes equal to the index of the comma, so pos !== i evaluates to false, causing the token before the comma to be dropped completely.

This PR:

  • Fixes parse() to locate tokens between delimiters and trim leading/trailing whitespace (spaces and tabs per RFC 9110 OWS rules) without dropping tokens.
  • Improves parsing performance using charCodeAt.
  • Adds unit tests covering tokens with whitespace before commas and tabs.
  • Ensures all existing and new tests pass with 100% test coverage.

This branch has not been deployed

No deployments
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.

bug: header tokens with whitespace preceding commas are dropped in vary parser

1 participant