From: Amos Jeffries Date: Sun, 11 Nov 2012 05:10:59 +0000 (+1300) Subject: Audit result changes X-Git-Tag: SQUID_3_4_0_1~471^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=24eac8306a62e79fde8cb66f70cebf91349e6a04;p=thirdparty%2Fsquid.git Audit result changes --- diff --git a/src/HelperReply.cc b/src/HelperReply.cc index 08314f8a81..d12499a2e0 100644 --- a/src/HelperReply.cc +++ b/src/HelperReply.cc @@ -124,10 +124,15 @@ HelperReply::parseResponseKeys() if (*p != '=') return; // done. Not a key. + // whitespace between key and value is prohibited. + // workaround strwordtok() which skips whitespace prefix. + if (xisspace(*(p+1))) + return; // done. Not a key. + *p = '\0'; ++p; - String key(other().content()); + const String key(other().content()); // the value may be a quoted string or a token const bool urlDecode = (*p != '"'); // check before moving p. @@ -139,7 +144,7 @@ HelperReply::parseResponseKeys() responseKeys.add(key, value); modifiableOther().consume(p - other().content()); - modifiableOther().consumeWhitespace(); + modifiableOther().consumeWhitespacePrefix(); } } diff --git a/src/MemBuf.cc b/src/MemBuf.cc index 682d904eec..4777e18fba 100644 --- a/src/MemBuf.cc +++ b/src/MemBuf.cc @@ -221,14 +221,16 @@ void MemBuf::consume(mb_size_t shiftSize) } /// removes all whitespace prefix bytes and "packs" by moving content left -void MemBuf::consumeWhitespace() +void MemBuf::consumeWhitespacePrefix() { PROF_start(MemBuf_consumeWhitespace); - const char *end = buf + contentSize(); - const char *p = buf; - for(; p<=end && xisspace(*p); ++p); - if (p-buf > 0) - consume(p-buf); + if (contentSize() > 0) { + const char *end = buf + contentSize(); + const char *p = buf; + for(; p 0) + consume(p-buf); + } PROF_stop(MemBuf_consumeWhitespace); } diff --git a/src/MemBuf.h b/src/MemBuf.h index 421ac71ce6..e28124ff33 100644 --- a/src/MemBuf.h +++ b/src/MemBuf.h @@ -81,7 +81,7 @@ public: /// \note there is currently no stretch() method to grow without appending void consume(mb_size_t sz); // removes sz bytes, moving content left - void consumeWhitespace(); // removes all prefix whitespace, moving content left + void consumeWhitespacePrefix(); ///< removes all prefix whitespace, moving content left void append(const char *c, mb_size_t sz); // grows if needed and possible void appended(mb_size_t sz); // updates content size after external append diff --git a/src/cf.data.pre b/src/cf.data.pre index b85d5d560f..311121f030 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -715,11 +715,15 @@ DOC_START All response keyword values need to be a single token with URL escaping, or enclosed in double quotes (") and escaped using \ on - any quotes, whitespace or \ characters within the value - For example: - user="John\ Smith" - user="J.\ O\'Brien" + any double quotes or \ characters within the value. The wrapping + double quotes are removed before the value is interpreted by Squid. + \r and \n are also replace by CR and LF. + + Some example key values: + user=John%20Smith + user="John Smith" + user="J. \"Bob\" Smith" DOC_END NAME: acl @@ -4131,12 +4135,12 @@ DOC_START For each requested URL, the rewriter will receive on line with the format - [channel-ID ] URL client_ip "/" fqdn user method [ kvpairs] + [channel-ID ] URL client_ip "/" fqdn user method [ kv-pairs] After processing the request the helper must reply using the following format: - [channel-ID ] result [ kvpairs] + [channel-ID ] result [ kv-pairs] The result code can be: @@ -4161,7 +4165,7 @@ DOC_START In the future, the interface protocol will be extended with - key=value pairs ("kvpairs" shown above). Helper programs + key=value pairs ("kv-pairs" shown above). Helper programs should be prepared to receive and possibly ignore additional whitespace-separated tokens on each input line.