BUG/MINOR: h1: restrict a bit more the syntax of chunk extensions
This is a complement of commit
35d63cc3c7 ("MEDIUM: h1: strictly verify
quoting in chunk extensions") in 3.4-dev4, which focused on better
dealing with quotes in chunk extensions due to some agents being
confused by the quotes there. The exact syntax of chunk extensions is:
*( BWS ';' BWS <name> [ BWS '=' BWS <value> ] )
where:
name: <token>
value: <token> / <quoted_string>
BWS stands for "bad whitespace", a WS that might be received from legacy
senders but that new ones must not send.
There were a few aspects above that we didn't check:
- no space is permitted before the CRLF
- the value may not be empty
- name must exclusively be a token
- value must exclusively be a token if not a quoted string
This is important because bad parsers have been caught in the past
swalloing the CRLF at wrong places (inside quotes mainly), and we must
make sure that we're not receiving a mis-quoted extension that could
have fooled an upstream reverse-proxy that got its framing wrong.
This commit improves the state machine to take care ofthe equal sign,
check for BWS around and non-empty value, and make sure that <name>
is a token. It looks like a big change but actually it's a linear
parsing of simple elements and it simplifies the previous parser
that was relying on multiple states in a loop and was wrong.
This is marked minor because most of the sensitive job was in the
commit above, this one only slightly tightens it (and anyway nobody
uses chunk extensions). It could make sense to backport this where
the commit above was backported, after a period of observation.