Error compiling VCL when using '% in regexp

Naama Bamberger naamab at answers.com
Sun Feb 7 16:20:19 CET 2010


I'm trying to handle bad requests sent to the servers, by eliminating problematic suffixes.
We had a lot of requests lately, ending by a percent sign and a single digit, that returned 503.

I tried adding this code to remove the 2 last characters of the URL, but the compilation fails.

                # If the URL ends with % and one digit (a broken hex value) - remove the last 2 characters.
                if (req.url ~ "(.*)%[0-9a-fA-F]$") {
                                set req.url = regsub(req.url, "(.*)%[0-9a-fA-F]$", "\1");
                }

I get this error:

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

I tried adding '\' before the '%' sign, with no success.

Thanks for your help,
Naama
Answers.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20100207/8d677bd5/attachment-0001.html>


More information about the varnish-misc mailing list