]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: cache: recognize null qvalues with decimals in Accept-Encoding
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 21 Oct 2026 08:37:22 +0000 (08:37 +0000)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 12 Nov 2026 17:20:31 +0000 (18:20 +0100)
commite97e1309ce1d7f4582b5c4228331c181962b6f7d
tree81382a19fb5b985109f424df8be4faa25e487508
parentc41bc79b1b493c8441024a9df6d9bb3d30888014
BUG/MINOR: cache: recognize null qvalues with decimals in Accept-Encoding

With "process-vary on", a client refusing an encoding with a null weight
written with decimals, such as "Accept-Encoding: gzip;q=0.0, deflate", may
be delivered a cached gzip-encoded response, that it explicitly refused
and may not be able to decode. Only the client issuing such a request is
affected, it receives an encoding it cannot process.

The accept-encoding normalizer builds a bitmap of the accepted encodings,
from which the ones with a null weight are removed. A null weight was only
detected when the parameter was exactly "q=0", while RFC 9110#12.4.2
defines a qvalue as ( "0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] ),
so "q=0.", "q=0.0", "q=0.00" and "q=0.000" are null weights as well. They
were considered as non-null, the encoding was accepted and a cached
response with this encoding matched the request's secondary key.

The weight is now considered null when "q=0" is only followed by an
optional dot and zeroes.

The reg-test reg-tests/cache/vary_accept_encoding.vtc is extended: it
stores a gzip response then sends requests refusing gzip with "q=0.0" or
"q=0.000". It fails without the fix since the cached gzip response is
delivered.

This patch may be backported to all supported versions.
reg-tests/cache/vary_accept_encoding.vtc
src/cache.c