r5223 - in trunk/varnish-cache: bin/varnishtest/tests doc/sphinx/reference lib/libvcl

phk at varnish-cache.org phk at varnish-cache.org
Mon Sep 20 14:57:43 CEST 2010


Author: phk
Date: 2010-09-20 14:57:43 +0200 (Mon, 20 Sep 2010)
New Revision: 5223

Modified:
   trunk/varnish-cache/bin/varnishtest/tests/v00019.vtc
   trunk/varnish-cache/doc/sphinx/reference/vcl.rst
   trunk/varnish-cache/lib/libvcl/vcc_token.c
Log:
Drop %xx escapes in VCL strings, in order to simplify things.



Modified: trunk/varnish-cache/bin/varnishtest/tests/v00019.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00019.vtc	2010-09-17 10:34:25 UTC (rev 5222)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00019.vtc	2010-09-20 12:57:43 UTC (rev 5223)
@@ -4,28 +4,8 @@
 
 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
 	sub vcl_recv { set req.url = "x"; }
 }

Modified: trunk/varnish-cache/doc/sphinx/reference/vcl.rst
===================================================================
--- trunk/varnish-cache/doc/sphinx/reference/vcl.rst	2010-09-17 10:34:25 UTC (rev 5222)
+++ trunk/varnish-cache/doc/sphinx/reference/vcl.rst	2010-09-20 12:57:43 UTC (rev 5223)
@@ -40,12 +40,11 @@
 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

Modified: trunk/varnish-cache/lib/libvcl/vcc_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_token.c	2010-09-17 10:34:25 UTC (rev 5222)
+++ trunk/varnish-cache/lib/libvcl/vcc_token.c	2010-09-20 12:57:43 UTC (rev 5223)
@@ -339,64 +339,22 @@
 }
 
 /*--------------------------------------------------------------------
- * 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);
 }
 




More information about the varnish-commit mailing list