fix(etag): match If-None-Match tags with optional whitespace before the comma (#5222)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* fix(etag): match If-None-Match tags with optional whitespace before the comma etagMatches split the header with /,\s*/, which only consumes whitespace after each comma. RFC 9110 defines If-None-Match as a #entity-tag list, and the list rule permits optional whitespace on both sides of the delimiter. When whitespace preceded a comma (e.g. `"a" , "b"`), the preceding tag kept a trailing space, so stripWeak('"a" ') never equalled stripWeak('"a"') and the match failed, returning 200 instead of 304 for a tag that was present. Trim the header and split on /\s*,\s*/ so OWS on either side of the comma is consumed. * fix(etag): split If-None-Match on comma then trim to avoid ReDoS Per review feedback, replace the `/\s*,\s*/` split with `split(',')` and a per-token `trim()`, so there is no regex backtracking. This matches the pattern already used in serve-static and still handles optional whitespace on either side of the comma.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+10 added−1 removed
- tests:+8 added−0 removed
- other:+2 added−1 removed