mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-02 01:33:04 +00:00
Bug fixes
Fix when importing rulesets, some invisible characters are also added to the result. Fix proxy group/ruleset settings not working properly with YAML format external configurations.
This commit is contained in:
4 files changed
+24
-1
No files matched your search
+3
-1
@@ -249,6 +249,7 @@ void readGroup(YAML::Node node, string_array &dest)
|
|||||||
|
|
||||||
for(i = 0; i < node.size(); i++)
|
for(i = 0; i < node.size(); i++)
|
||||||
{
|
{
|
||||||
|
name.clear();
|
||||||
eraseElements(tempArray);
|
eraseElements(tempArray);
|
||||||
object = node[i];
|
object = node[i];
|
||||||
object["import"] >> name;
|
object["import"] >> name;
|
||||||
@@ -292,7 +293,8 @@ void readRuleset(YAML::Node node, string_array &dest)
|
|||||||
|
|
||||||
for(unsigned int i = 0; i < node.size(); i++)
|
for(unsigned int i = 0; i < node.size(); i++)
|
||||||
{
|
{
|
||||||
name = "";
|
url.clear();
|
||||||
|
name.clear();
|
||||||
object = node[i];
|
object = node[i];
|
||||||
object["import"] >> name;
|
object["import"] >> name;
|
||||||
if(name.size())
|
if(name.size())
|
||||||
|
|||||||
@@ -618,8 +618,14 @@ bool regValid(const std::string &target)
|
|||||||
jp::Regex reg(target);
|
jp::Regex reg(target);
|
||||||
return !!reg;
|
return !!reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // USE_STD_REGEX
|
#endif // USE_STD_REGEX
|
||||||
|
|
||||||
|
std::string regTrim(const std::string &src)
|
||||||
|
{
|
||||||
|
return regReplace(src, "^\\s*?(.*?)\\s*$", "$1");
|
||||||
|
}
|
||||||
|
|
||||||
std::string speedCalc(double speed)
|
std::string speedCalc(double speed)
|
||||||
{
|
{
|
||||||
if(speed == 0.0)
|
if(speed == 0.0)
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ bool regValid(const std::string &target);
|
|||||||
bool regFind(const std::string &src, const std::string &match);
|
bool regFind(const std::string &src, const std::string &match);
|
||||||
std::string regReplace(const std::string &src, const std::string &match, const std::string &rep);
|
std::string regReplace(const std::string &src, const std::string &match, const std::string &rep);
|
||||||
bool regMatch(const std::string &src, const std::string &match);
|
bool regMatch(const std::string &src, const std::string &match);
|
||||||
|
std::string regTrim(const std::string &src);
|
||||||
std::string speedCalc(double speed);
|
std::string speedCalc(double speed);
|
||||||
std::string getMD5(const std::string &data);
|
std::string getMD5(const std::string &data);
|
||||||
bool isIPv4(const std::string &address);
|
bool isIPv4(const std::string &address);
|
||||||
|
|||||||
@@ -403,11 +403,18 @@ void rulesetToClash(YAML::Node &base_rule, std::vector<ruleset_content> &ruleset
|
|||||||
while(getline(strStrm, strLine, delimiter))
|
while(getline(strStrm, strLine, delimiter))
|
||||||
{
|
{
|
||||||
lineSize = strLine.size();
|
lineSize = strLine.size();
|
||||||
|
/*
|
||||||
if(lineSize && strLine[lineSize - 1] == '\r') //remove line break
|
if(lineSize && strLine[lineSize - 1] == '\r') //remove line break
|
||||||
{
|
{
|
||||||
strLine.erase(lineSize - 1);
|
strLine.erase(lineSize - 1);
|
||||||
lineSize--;
|
lineSize--;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
if(lineSize)
|
||||||
|
{
|
||||||
|
strLine = regTrim(strLine);
|
||||||
|
lineSize = strLine.size();
|
||||||
|
}
|
||||||
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
|
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
|
||||||
continue;
|
continue;
|
||||||
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
|
||||||
@@ -542,11 +549,18 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
|
|||||||
while(getline(strStrm, strLine, delimiter))
|
while(getline(strStrm, strLine, delimiter))
|
||||||
{
|
{
|
||||||
lineSize = strLine.size();
|
lineSize = strLine.size();
|
||||||
|
/*
|
||||||
if(lineSize && strLine[lineSize - 1] == '\r') //remove line break
|
if(lineSize && strLine[lineSize - 1] == '\r') //remove line break
|
||||||
{
|
{
|
||||||
strLine.erase(lineSize - 1);
|
strLine.erase(lineSize - 1);
|
||||||
lineSize--;
|
lineSize--;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
if(lineSize)
|
||||||
|
{
|
||||||
|
strLine = regTrim(strLine);
|
||||||
|
lineSize = strLine.size();
|
||||||
|
}
|
||||||
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
|
if(!lineSize || strLine[0] == ';' || strLine[0] == '#' || (lineSize >= 2 && strLine[0] == '/' && strLine[1] == '/')) //empty lines and comments are ignored
|
||||||
continue;
|
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
|
||||||
|
|||||||
Reference in new issue
Block a user