adding a double quote into a regsub in vcl_fetch

Stefan Caunter stef at scaleengine.com
Wed Oct 16 00:32:07 CEST 2013


On Tue, Oct 15, 2013 at 5:00 PM, Paul A. Procacci
<pprocacci at datapipe.com> wrote:
>>  if (req.url ~ "^/blah") {
>>                 set beresp.http.Link = regsub(req.url, "^/(blah).*",
>> "<http://example.com/blah>; rel=\" + "canonical" + " ");
>>                 return(deliver);
>>         }
>>
>
> set beresp.http.Link = regsub(req.url, '^/blah.*', '<http://example.com/blah>; rel="canonical" ');
>
> This maybe?

i tried single quotes initially, vcl seems to dislike single quoting
in regsub, and backslash escaping is also ineffective when trying to
print out a " character

Syntax error at
('input' Line 149 Pos 56)
                set beresp.http.Link = regsub(req.url, '^/blah.*',
'<http://example.com/blah>; rel="canonical" ');
-------------------------------------------------------#-------------------------------------------------------------

Running VCC-compiler failed, exit 1

if i put "^/blah.*", in double quotes, it shifts the error over to

('input' Line 149 Pos 71)
                set beresp.http.Link = regsub(req.url, "^/couples.*",
'<http://example.com/blah>; rel="canonical" ');

which is where the single quote tries to protect the double quote



More information about the varnish-misc mailing list