如何在varnish vcl中转义双引号

问题描述 投票:0回答:3

在vcl_recv中,我正在尝试向URL中包含以下字符的请求发送403:“,',<,>,(和)

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

一切都有效,除了双引号“我试过正则表达式:

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

所有这些都没有编译“varnishd -C -f default.vcl”我目前在varnish-4.1.1有谁知道如何逃避“正确?

varnish vcl varnish-vcl varnish-4
3个回答
4
投票

怎么样:

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

Regex test


2
投票

%22为我工作,我需要在Fastly界面内创建一个cookie函数

"location_data={%22geo.continent_code%22:%22"client.geo.continent_code"%22,%22geo.country_code%22:%22"client.geo.country_code"%22,%22geo.city.ascii%22:%22"client.geo.city.ascii"%22,%22geo.postal_code%22:%22"client.geo.postal_code"%22};Path=/"

1
投票

%22会在Varnish VCL的引用字符串中给你双引号

© www.soinside.com 2019 - 2024. All rights reserved.