isahdguaih / adfiltering-rules

Automatically exported from code.google.com/p/adfiltering-rules
0 stars 4 forks source link

转换脚本修复错误 #41

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
===改进内容===
修正转换脚本的已知转换错误问题
===改进步骤===
1.猎豹版中,带domain的也会成为白名单。可模拟ADSafe版,先行
处理白名单。
2.对于$domain限域规则,不支持的版本去除规则。
3.对于$domain=~排域规则,不支持的版本不排域。

Original issue reported on code.google.com by hc5023295 on 7 Feb 2013 at 2:22

GoogleCodeExporter commented 8 years ago
重构猎豹版转换,未完成的处理模块
if re.search('$', line):
    #先分类,分成非选项和过滤规则选项
    dotmatch = re.search(r'^([^$]*)(.*)$), line)
    dotdomain = dotmatch.group(1)
    dotother = dotmatch.group(2)
    #先像普通规则那样处理非选项
    dotdomain = re.sub('.', '\.', dotdomain)
    dotdomain = re.sub(r'\|$', '$' ,dotdomain)
    dotdomain = re.sub('/', '\/', dotdomain)
    dotdomain = re.sub('*', '\*', dotdomain)
    dotdomain = re.sub('?', '\?', dotdomain)
    dotdomain = re.sub(r'^\|\|', '/:\/\/([^\/]+\.)?', dotdomain)
    #再处理过滤规则选项
    dotother = re.sub('object-subrequest', 'object', dotother)
    dotother = re.sub('subdocument', 'document', dotother)
    dotother = re.sub('subdocument', 'document', dotother)
    dotother = re.sub(',', '|', dotother)
    if re.search(r'\$.*\$', dotother):
        dotother = re.sub(r'    $w', ',$w', dotother)
    line = dotdomain + '    ' + dotother

else:
    line = re.sub('.', '\.', line)
    line = re.sub(r'\|$', '$' ,line)
    line = re.sub('/', '\/', line)
    line = re.sub('*', '\*', line)
    line = re.sub('?', '\?', line)
    line = re.sub(r'^\|\|', '/:\/\/([^\/]+\.)?', line)

Original comment by hc5023295 on 8 Feb 2013 at 6:18

GoogleCodeExporter commented 8 years ago
完成于 r889

Original comment by hc5023295 on 8 Feb 2013 at 11:47