Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape a double quote in varnish vcl

In vcl_recv I'm trying to send a 403 to requests that contain the following characters in the url: ",',<,>,(, and )

if(req.url ~ "[\'\<\>()].*\.html" ) {
  return (synth(403, "Forbidden"));
}

everything works except the double quote " I tried regex like:

"[\"\'\<\>()].*\.html"
"[\\"\'\<\>()].*\.html"
"[%22\'\<\>()].*\.html"
"[x22\'\<\>()].*\.html"

All of them do not compile with "varnishd -C -f default.vcl" I'm currently on varnish-4.1.1 Does anyone know how to escape the " correctly?

like image 637
Boris Burgstaller Avatar asked Feb 05 '23 10:02

Boris Burgstaller


1 Answers

How about:

if (req.url ~ "[\x27<>()\x22]") {
    return (synth(403, "Forbidden"));
}

Regex test

like image 200
Danila Vershinin Avatar answered Mar 15 '23 17:03

Danila Vershinin