Commit 0ae4d096 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Drop %xx escapes in VCL strings, in order to simplify things.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5223 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 70ce9290
......@@ -4,26 +4,6 @@ test "VCL compiler coverage test: vcc_token.c"
varnish v1 -badvcl " C{ "
varnish v1 -badvcl {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { set req.url = "%/"; }
}
varnish v1 -badvcl {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { set req.url = "%a/"; }
}
varnish v1 -vcl {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { set req.url = "%4a"; }
}
varnish v1 -badvcl {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { set req.url = "%0a"; }
}
varnish v1 -vcl {
backend b { .host = "127.0.0.1"; }
# comment
......
......@@ -40,12 +40,11 @@ In addition to the C-like assignment (=), comparison (==) and boolean
matching using the ~ operator.
Unlike C and Perl, the backslash (\) character has no special meaning
in strings in VCL, which use the (%xx) escape mechanism just like
URLs, so it can be freely used in regular expressions without
doubling.
in strings in VCL, so it can be freely used in regular expressions
without doubling.
Strings are concatenated by just putting them one after each other
without any operator in between.
Strings are concatenated by putting them one after each other
without a '+' operator between.
Assignments are introduced with the set keyword. There are no
user-defined variables; values can only be assigned to variables
......
......@@ -339,64 +339,22 @@ vcc_ExpectCid(struct vcc *tl)
}
/*--------------------------------------------------------------------
* Decode %xx in a string
* Decode a string
*/
static int8_t
vcc_xdig(const char c)
{
static const char * const xdigit =
"0123456789abcdef"
"0123456789ABCDEF";
const char *p;
p = strchr(xdigit, c);
assert(p != NULL);
return ((p - xdigit) % 16);
}
static int
vcc_decstr(struct vcc *tl)
{
const char *p;
char *q;
unsigned char u;
unsigned char l;
assert(tl->t->tok == CSTR);
tl->t->dec = TlAlloc(tl, (tl->t->e - tl->t->b) - 1);
l = (tl->t->e - tl->t->b) - 2;
tl->t->dec = TlAlloc(tl, l + 1);
assert(tl->t->dec != NULL);
q = tl->t->dec;
for (p = tl->t->b + 1; p < tl->t->e - 1; ) {
if (*p != '%') {
*q++ = *p++;
continue;
}
if (p + 4 > tl->t->e) {
vcc_AddToken(tl, CSTR, p, tl->t->e);
vsb_printf(tl->sb,
"Incomplete %%xx escape\n");
vcc_ErrWhere(tl, tl->t);
return(1);
}
if (!isxdigit(p[1]) || !isxdigit(p[2])) {
vcc_AddToken(tl, CSTR, p, p + 3);
vsb_printf(tl->sb,
"Invalid hex char in %%xx escape\n");
vcc_ErrWhere(tl, tl->t);
return(1);
}
u = (vcc_xdig(p[1]) * 16 + vcc_xdig(p[2])) & 0xff;
if (!isgraph(u)) {
vcc_AddToken(tl, CSTR, p, p + 3);
vsb_printf(tl->sb,
"Control character in %%xx escape\n");
vcc_ErrWhere(tl, tl->t);
return(1);
}
*q++ = u;
p += 3;
}
*q++ = '\0';
memcpy(q, tl->t->b + 1, l);
q[l] = '\0';
return (0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment