adding a double quote into a regsub in vcl_fetch

Stefan Caunter stef at scaleengine.com
Wed Oct 16 01:16:45 CEST 2013


On Tue, Oct 15, 2013 at 7:03 PM, Paul A. Procacci
<pprocacci at datapipe.com> wrote:
> Yep,
>
> I see that now.  Didn't realize the parser was that picky.
>
> "
>
> Can you use the above in place of a double quote?
>
> I.E:
>   set beresp.http.Link = regsub(req.url, "^/blah.*", "<http://example.com/blah>; rel="canonical" ");
>

it faithfully prints that out

Link: <http://example.com/blah>; rel="canonical"

>
>
> On Tue, Oct 15, 2013 at 06:32:07PM -0400, Stefan Caunter wrote:
>> 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
>
> ________________________________
>
> This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you. Unless otherwise specified in a written agreement, this e-mail neither constitutes an agreement to conduct transactions by electronic means nor creates any legally binding contract or enforceable agreement.



More information about the varnish-misc mailing list