Skip to content

Fix Accept-Encoding matching in compression middleware - #1200

Open
rupayon123 wants to merge 1 commit into
go-chi:masterfrom
rupayon123:contribution/accept-encoding-qvalue-20261002
Open

rupayon123 wants to merge 1 commit into
go-chi:masterfrom
rupayon123:contribution/accept-encoding-qvalue-20261002

Conversation

@rupayon123

Copy link
Copy Markdown

Summary

Fix Accept-Encoding matching in compression middleware by comparing complete encoding tokens and respecting q=0. This prevents unsupported substring matches such as bgzip matching gzip and stops compression when a client explicitly marks an encoding unacceptable. Quality values outside the supported 0 < q <= 1 range are ignored as invalid.

Fixes #1069.

Validation

  • Added table-driven cases for exact and case-insensitive tokens, whitespace, positive and zero quality values, invalid/out-of-range quality values, and substring false positives.
  • Confirmed the regression tests fail against the original implementation.
  • go test ./middleware -run '^TestMatchAcceptEncoding$' -count=1 passed.
  • go test ./middleware -count=1 passed.
  • go test ./... -count=1 passed.
  • go vet ./... and git diff --check passed.

This change was prepared with AI assistance at the account holder's direction; the account holder is responsible for this submission and will handle any required project-specific process.

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.

Compress middleware: matchAcceptEncoding uses substring match and ignores q=0

1 participant