]> git.kaiwu.me - haproxy.git/commit
MINOR: http: speed up http_header_has_forbidden_char() to make it work alone
authorWilly Tarreau <w@1wt.eu>
Wed, 4 Nov 2026 09:58:53 +0000 (10:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 4 Nov 2026 21:45:33 +0000 (22:45 +0100)
commitde80a2699cddb10a475d9c90c0ad1225f83bd556
tree7ff9b7ad16f2e007f4674d8cbe139c4142331f72
parent4f777a626805123f5356546736c121ab40c68576
MINOR: http: speed up http_header_has_forbidden_char() to make it work alone

The function reads one char at a time and is systematically hidden behind
a first call to ist_find_http_ctl() to speed up the lookup of control chars.
Unfortunately, this construct doesn't permit to find other control chars
such as 0x7F. Better make http_header_has_forbidden_char() self-sustaining,
but for this we need to implement the speedup there. For this, we start
with a loop using is_char8_outside(0x20,0x7e) that allows to fly over most
non-offending bytes (SP, VCHAR). Only HT (9) and obs-text (0x80..0xFF) will
exit early, which is not a problem given that they are extremely rare in
header values. After that we continue the loop to search for offending
bytes starting from the block of 4 or 8 that triggered.
include/haproxy/http.h