Error compiling VCL when using '% in regexp

Naama Bamberger naamab at answers.com
Tue Feb 9 14:40:17 CET 2010


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");
	}

Thanks for your help, 
Naama

-----Original Message-----
From: phk at critter.freebsd.dk [mailto:phk at critter.freebsd.dk] On Behalf Of Poul-Henning Kamp
Sent: Monday, February 08, 2010 12:53 PM
To: Naama Bamberger
Cc: varnish-misc at projects.linpro.no
Subject: Re: Error compiling VCL when using '% in regexp 

In message <DD929CD9109B0A4D8C34B732A6D35CC43C34E274 at MBX03.exg5.exghost.com>, Naama Bamberger writes:

>I get this error:
>
>Invalid hex char in %xx escape
>(input Line 107 Pos 28)
>        if (req.url ~ "(.*)%[0-9a-fA-F]$") {
>---------------------------###--------------
>

Try: %25

One of the decisions I had most trouble with, was deciding which
kind of escape-mechanism we wanted for strings in VCL.

In the end I settled for URL-%xx encoding, because I pressume
webmasters know it, and because it avoids a nightmare of back-slashes
in regexps.

I'm not 100% convinced that was the perfect decision...

-- 
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