[PATCH] match empty header field values using req_header

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Wed, 21 Nov 2012 18:44:06 -0700

Hello,

    Squid req_header ACL cannot match valid HTTP headers with empty
values. The attached patch makes it possible. I tried to limit the
changes to address this specific use case. It would be good to also
review other HttpHeader::get*() uses to check whether they mistreat
empty header fields, but that task is left for another volunteer.

Warning: Some req_header and rep_header ACLs that were [accidentally]
not matching empty headers (e.g., "^$" or ".*") will now start matching
them.

A new HttpHeader::getByNameIfPresent() method is added to be able to
detect presence of empty header fields while ACLHTTPHeaderData::match()
is adjusted to convert undefined String values into empty c-strings ("")
for ACLRegexData::match() to work.

Prior to these changes, when trying to match an empty header value with
a regex like "^$", ACLHTTPHeaderData::match() would return false because:

* HttpHeader::getStrOrList() and getByName() return an undefined String.
* String::termedBuf() returns NULL for undefined Strings; and
* ACLRegexData::match() always fails on NULL c-strings.

Thank you,

Alex.
P.S. This v3.2 patch needs a fuzz factor to apply to current trunk.

Received on Thu Nov 22 2012 - 01:44:16 MST

This archive was generated by hypermail 2.2.0 : Thu Nov 22 2012 - 12:00:08 MST