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.
responseKeys.add(key, value);
modifiableOther().consume(p - other().content());
- modifiableOther().consumeWhitespace();
+ modifiableOther().consumeWhitespacePrefix();
}
}
}
/// 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<end && xisspace(*p); ++p);
+ if (p-buf > 0)
+ consume(p-buf);
+ }
PROF_stop(MemBuf_consumeWhitespace);
}
/// \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
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
For each requested URL, the rewriter will receive on line with the format
- [channel-ID <SP>] URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kvpairs]<NL>
+ [channel-ID <SP>] URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kv-pairs]<NL>
After processing the request the helper must reply using the following format:
- [channel-ID <SP>] result [<SP> kvpairs]
+ [channel-ID <SP>] result [<SP> kv-pairs]
The result code can be:
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.