mirror of
https://github.com/MetaCubeX/subconverter.git
synced 2025-11-04 18:19:42 +08:00
Fix a bug which may cause some comments in rulesets not being filtered
This commit is contained in:
parent
3eefeb740e
commit
6f64f27361
@ -320,11 +320,13 @@ void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset
|
|||||||
|
|
||||||
strStrm.clear();
|
strStrm.clear();
|
||||||
strStrm<<retrived_rules;
|
strStrm<<retrived_rules;
|
||||||
|
std::string::size_type lineSize;
|
||||||
while(getline(strStrm, strLine, delimiter))
|
while(getline(strStrm, strLine, delimiter))
|
||||||
{
|
{
|
||||||
strLine = replace_all_distinct(strLine, "\r", ""); //remove line break
|
lineSize = strLine.size();
|
||||||
if(!strLine.size() || strLine.find("#") == 0 || strLine.find(";") == 0) //remove comments
|
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
|
||||||
continue;
|
continue;
|
||||||
|
strLine = replace_all_distinct(strLine, "\r", ""); //remove line break
|
||||||
if(strLine.find("USER-AGENT") == 0 || strLine.find("URL-REGEX") == 0 || strLine.find("PROCESS-NAME") == 0 || strLine.find("AND") == 0 || strLine.find("OR") == 0) //remove unsupported types
|
if(strLine.find("USER-AGENT") == 0 || strLine.find("URL-REGEX") == 0 || strLine.find("PROCESS-NAME") == 0 || strLine.find("AND") == 0 || strLine.find("OR") == 0) //remove unsupported types
|
||||||
continue;
|
continue;
|
||||||
/*
|
/*
|
||||||
@ -417,13 +419,15 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
|
|||||||
|
|
||||||
strStrm.clear();
|
strStrm.clear();
|
||||||
strStrm<<retrived_rules;
|
strStrm<<retrived_rules;
|
||||||
|
std::string::size_type lineSize;
|
||||||
while(getline(strStrm, strLine, delimiter))
|
while(getline(strStrm, strLine, delimiter))
|
||||||
{
|
{
|
||||||
|
lineSize = strLine.size();
|
||||||
|
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
|
||||||
|
continue;
|
||||||
if((surge_ver == -1 || surge_ver == -2) && (strLine.find("IP-CIDR6") == 0 || strLine.find("URL-REGEX") == 0 || strLine.find("PROCESS-NAME") == 0 || strLine.find("AND") == 0 || strLine.find("OR") == 0)) //remove unsupported types
|
if((surge_ver == -1 || surge_ver == -2) && (strLine.find("IP-CIDR6") == 0 || strLine.find("URL-REGEX") == 0 || strLine.find("PROCESS-NAME") == 0 || strLine.find("AND") == 0 || strLine.find("OR") == 0)) //remove unsupported types
|
||||||
continue;
|
continue;
|
||||||
strLine = replace_all_distinct(strLine, "\r", ""); //remove line break
|
strLine = replace_all_distinct(strLine, "\r", ""); //remove line break
|
||||||
if(!strLine.size() || strLine.find("#") == 0 || strLine.find(";") == 0) //remove comments
|
|
||||||
continue;
|
|
||||||
strLine += "," + rule_group;
|
strLine += "," + rule_group;
|
||||||
if(surge_ver == -1 || surge_ver == -2)
|
if(surge_ver == -1 || surge_ver == -2)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user