privacy-protection-tools / anti-AD

致力于成为中文区命中率最高的广告过滤列表,实现精确的广告屏蔽和隐私保护。anti-AD现已支持AdGuardHome,dnsmasq, Surge,Pi-Hole,smartdns等网络组件。完全兼容常见的广告过滤工具所支持的各种广告过滤列表格式
https://anti-ad.net
MIT License
8.41k stars 727 forks source link

Avoid blocking domains that should be allowed #718

Closed MkQtS closed 1 year ago

MkQtS commented 1 year ago

在easylist的语法中,形如||example.com^$~image表示拦截来自example.com的所有连接除非是image类型,也就是放行来自example.comimage。那么anti-ad作为域名级的拦截列表应该放过example.com

原脚本中的正则判断:

if(preg_match('/^\|\|([0-9a-z\-\.]+[a-z]+)\^(\$([^=]+?,)?(image|third-party|script)(,[^=]+)?)?$/', $line, $matches))

没有涉及到~这一字符。||example.com^$~image,script^这类上游规则符合此处判断条件,其中的域名会被anti-ad拦截。实际上已有这样的例子,比如目前||bestcontactform.com^$~image,third-party中的bestcontactform.com||70e.com^$third-party,~script中的70e.com被拦截了。

这一PR能修复此问题。