MINOR: http-act: emit a warning when a header field name contains forbidden chars
authorWilly Tarreau <w@1wt.eu>
Tue, 4 Apr 2023 03:25:16 +0000 (05:25 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 4 Apr 2023 03:38:01 +0000 (05:38 +0200)
commitdb12c0dd1049f7ac48b3145884439d722ad8c434
treebeb2681a8a9b0c83c710f01d44456f6fc1279d1a
parentc877bd4ea5dba14738bbf565df13d3016eb52bb3
MINOR: http-act: emit a warning when a header field name contains forbidden chars

As found in issue #2089, it's easy to mistakenly paste a colon in a
header name, or other chars (e.g. spaces) when quotes are in use, and
this causes all sort of trouble in field because such chars are rejected
by the peer.

Better try to detect these upfront. That's what we're doing here during
the parsing of the add-header/set-header/early-hint actions, where a
warning is emitted if a non-token character is found in a header name.
A special case is made for the colon at the beginning so that it remains
possible to place any future pseudo-headers that may appear. E.g:

  [WARNING]  (14388) : config : parsing [badchar.cfg:23] : header name 'X-Content-Type-Options:' contains forbidden character ':'.

This should be backported to 2.7, and ideally it should be turned to an
error in future versions.
src/http_act.c