#
-# $Id: cf.data.pre,v 1.353 2004/08/04 16:22:39 wessels Exp $
+# $Id: cf.data.pre,v 1.354 2004/08/14 21:15:15 hno Exp $
#
#
# SQUID Web Proxy Cache http://www.squid-cache.org/
grace=n Percentage remaining of TTL where a refresh of a
cached entry should be initiated without needing to
wait for a new reply. (default 0 for no grace period)
+ protocol=2.5 Compatibility mode for Squid-2.5 external acl helpers
FORMAT specifications
The helper receives lines per the above format specification,
and returns lines starting with OK or ERR indicating the validity
of the request and optionally followed by additional keywords with
- more details.
+ more details. To protect from odd characters the data is URL
+ escaped.
General result syntax:
log= String to be logged in access.log. Available as
%ea in logformat specifications
- Keyword values need to be enclosed in quotes if they may
- contain whitespace, or the whitespace escaped using \. Any
- quotes or \ characters within the keyword value must be \
- escaped.
+ Keyword values need to be URL escaped if they may contain
+ contain whitespace or quotes.
+
+ In Squid-2.5 compatibility mode quoting using " and \ is used
+ instead of URL escaping.
DOC_END
COMMENT_START
/*
- * $Id: external_acl.cc,v 1.55 2003/11/19 17:18:35 hno Exp $
+ * $Id: external_acl.cc,v 1.56 2004/08/14 21:15:16 hno Exp $
*
* DEBUG: section 82 External ACL
* AUTHOR: Henrik Nordstrom, MARA Systems AB
dlink_list queue;
int require_auth;
+
+ enum
+ {
+ QUOTE_METHOD_SHELL = 1,
+ QUOTE_METHOD_URL
+ }
+
+ quote;
};
struct _external_acl_format
token = strtok(NULL, w_space);
+ a->quote = external_acl::QUOTE_METHOD_URL;
+
/* Parse options */
while (token) {
if (strncmp(token, "ttl=", 4) == 0) {
a->cache_size = atoi(token + 6);
} else if (strncmp(token, "grace=", 6) == 0) {
a->grace = atoi(token + 6);
+ } else if (strcmp(token, "protocol=2.5") == 0) {
+ a->quote = external_acl::QUOTE_METHOD_SHELL;
+ } else if (strcmp(token, "protocol=3.0") == 0) {
+ a->quote = external_acl::QUOTE_METHOD_URL;
+ } else if (strcmp(token, "quote=url") == 0) {
+ a->quote = external_acl::QUOTE_METHOD_URL;
+ } else if (strcmp(token, "quote=shell") == 0) {
+ a->quote = external_acl::QUOTE_METHOD_SHELL;
} else {
break;
}
storeAppendPrintf(sentry, " %%{%s:%s}", format->header, format->member);
break;
#define DUMP_EXT_ACL_TYPE(a) \
- case _external_acl_format::EXT_ACL_##a: \
- storeAppendPrintf(sentry, " %%%s", #a); \
- break
+ case _external_acl_format::EXT_ACL_##a: \
+ storeAppendPrintf(sentry, " %%%s", #a); \
+ break
DUMP_EXT_ACL_TYPE(LOGIN);
#if USE_IDENT
if (!first)
memBufAppend(&mb, " ", 1);
- strwordquote(&mb, str);
+ if (acl_data->def->quote == external_acl::QUOTE_METHOD_URL) {
+ const char *quoted = rfc1738_escape(str);
+ memBufAppend(&mb, quoted, strlen(quoted));
+ } else {
+ strwordquote(&mb, str);
+ }
sb.clean();
if (!first)
memBufAppend(&mb, " ", 1);
- strwordquote(&mb, arg->key);
+ if (acl_data->def->quote == external_acl::QUOTE_METHOD_URL) {
+ const char *quoted = rfc1738_escape(arg->key);
+ memBufAppend(&mb, quoted, strlen(quoted));
+ } else {
+ strwordquote(&mb, arg->key);
+ }
first = 0;
}
if (value) {
*value++ = '\0'; /* terminate the token, and move up to the value */
+ if (state->def->quote == external_acl::QUOTE_METHOD_URL)
+ rfc1738_unescape(value);
+
if (strcmp(token, "user") == 0)
entryData.user = value;
else if (strcmp(token, "message") == 0)
/*
- * $Id: tools.cc,v 1.240 2003/09/29 10:24:02 robertc Exp $
+ * $Id: tools.cc,v 1.241 2004/08/14 21:15:16 hno Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
case '\\':
p++;
- *d++ = ch = *p;
+
+ switch (*p) {
+
+ case 'n':
+ ch = '\n';
+
+ break;
+
+ case 'r':
+ ch = '\r';
+
+ break;
+
+ default:
+ ch = *p;
+
+ break;
+
+ }
+
+ *d++ = ch;
if (ch)
p++;
}
while (*str) {
- int l = strcspn(str, "\"\\");
+ int l = strcspn(str, "\"\\\n\r");
memBufAppend(mb, str, l);
str += l;
- while (*str == '"' || *str == '\\') {
+ switch(*str) {
+
+ case '\n':
+ memBufAppend(mb, "\\n", 2);
+ str++;
+ break;
+
+ case '\r':
+ memBufAppend(mb, "\\r", 2);
+ str++;
+ break;
+
+ case '\0':
+ break;
+
+ default:
memBufAppend(mb, "\\", 1);
memBufAppend(mb, str, 1);
str++;
+ break;
}
}