Skip to content

Conversation

simonwuelker
Copy link

@simonwuelker simonwuelker commented Sep 10, 2025

This behaviour matches other CORS headers like Access-Control-Allow-Headers and fixes a parsing bug.

As per https://httpwg.org/specs/rfc9110.html#abnf.extension, empty elements in the header are allowed, but previously AccessControlAllowHeaders::iter would incorrectly finish the returned iterator early due to take_while being used.

Technically, invalid elements in the header should cause an error, but this is not possible with the current interface (which parses the header incrementally as the iterator is advanced) and there's an argument to be made that relaxed parsing is fine too.

For context, this bug causes a WPT failure for servo in cors/request-headers.htm (See wpt.fyi). The test attempts to use ,y-lol,x-PriNT, ,,,Y-PRINT as a value for Access-Control-Allow-Headers (whose ABNF is #field-name 1).

Footnotes

  1. https://fetch.spec.whatwg.org/#http-new-header-syntax

…ders

This behaviour matches other CORS headers and fixes a parsing bug.

As per https://httpwg.org/specs/rfc9110.html#abnf.extension,
empty elements in the header are allowed, but previously this function
would incorrectly finish the iterator due to take_while being used.

Signed-off-by: Simon Wülker <[email protected]>
@simonwuelker
Copy link
Author

I'm not sure what the process for requesting a new release for this crate is, but it would be nice to have a new patch release when this is merged.

github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Sep 11, 2025
I added these comments while debugging `cors/request-headers.htm`.
Ultimately the bug turned out to be outside of servo, so we have to wait
for hyperium/headers#219.
Since that PR might take a while to merge I'd like to add these on their
own.

Signed-off-by: Simon Wülker <[email protected]>
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.

1 participant