Skip to content

fix(httpcache): keep a comma inside a quoted entity-tag in If-None-Match - #475

Merged
M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:fix/etag-quoted-comma
Nov 13, 2026
Merged

M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:fix/etag-quoted-comma

Conversation

@orcamedia

Copy link
Copy Markdown
Contributor

httpcache.ETagMatches split If-None-Match on every comma, including commas inside a quoted entity-tag. "release,1" therefore didn't match itself, and such a request got the full response instead of a 304.

Impact is low. OpenArtifact's own validators are hex digests (ContentETag, OriginTag), which never contain a comma. I didn't find a route that emits a tag with one. This fixes the helper so a future or passed-through tag behaves correctly; RFC 9110 allows commas in entity-tags.

Change

Commas separate list members only outside double quotes. An entity-tag has no escape syntax, so quotes simply pair up. Everything else is unchanged: the weak comparison (W/ ignored), *, and whitespace handling.

Tests

  • New table cases:

    • a comma inside a tag, alone and in a list with W/;
    • part of a comma tag doesn't match ("a,b" against "a");
    • a wildcard after a comma tag;
    • an unbalanced quote matches nothing after it;
    • empty list members.

    The existing cases pass unchanged.

  • FuzzETagMatches (in fuzz_test.go): any quote-free tag matches itself, alone and inside a list, and no input panics. It ran 20 s locally without a failure.

Checks

  • golangci-lint run ./... passes.
  • go test -short passes for internal/httpcache and its callers (internal/format/base, internal/proxy, web).
  • make deadcode passes.

🤖 Generated with Claude Code

ETagMatches split the header on every comma, so a tag such as
"release,1" never matched itself and the request got the full response
instead of a 304. Commas now separate list members only outside quotes
(an entity-tag has no escapes, so quotes pair up).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@M0Rf30
M0Rf30 merged commit 77ddec4 into openartifact:main Nov 13, 2026
23 checks passed
@orcamedia
orcamedia deleted the fix/etag-quoted-comma branch November 13, 2026 16:51
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