Error compiling VCL when using '% in regexp

Poul-Henning Kamp phk at phk.freebsd.dk
Wed Feb 10 11:10:14 CET 2010


In message <DD929CD9109B0A4D8C34B732A6D35CC43C403167 at MBX03.exg5.exghost.com>, N
aama Bamberger writes:
>I already tried using the escaped %25.
>The compilation succeeded, but the regexp didn't find a match in the problematic URLs:
>
>	# If the URL ends with % and one digit (a broken hex value) - remove the last 2 characters.
>	if (req.url ~ "(.*)%25[0-9a-fA-F]$") {
>		set req.url = regsub(req.url, "(.*)%25[0-9a-fA-F]$", "\1");
>	}

I just whipped up a varnishtest case, and it seems to work in -trunk:

	test "random test"

	server s1 {
		rxreq
		expect req.url == "/foo"
		txresp
	} -start

	varnish v1 -vcl+backend {

	sub vcl_recv {
		if (req.url ~ "(.*)%25[0-9a-fA-F]$") {
			set req.url = regsub(req.url, "(.*)%25[0-9a-fA-F]$", "\1");
		}
	}

	} -start

	client c1 {
		txreq -url /foo%a
		rxresp
	} -run

###  c1   Connect to 127.0.0.1:17621
###  c1   Connected to 127.0.0.1:17621 fd is 9
#### c1   txreq| GET /foo%a HTTP/1.1\r\n
#### c1   txreq| \r\n
###  c1   rxresp
###  s1   Accepted socket fd is 4
###  s1   rxreq
#### s1   rxhdr| GET /foo HTTP/1.1\r\n
#### s1   rxhdr| X-Forwarded-For: 127.0.0.1\r\n
#### s1   rxhdr| X-Varnish: 1001\r\n
#### s1   rxhdr| Host: 127.0.0.1\r\n
#### s1   rxhdr| \r\n


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



More information about the varnish-misc mailing list