mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-01 17:25:02 +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++)
|
||||
{
|
||||
name.clear();
|
||||
eraseElements(tempArray);
|
||||
object = node[i];
|
||||
object["import"] >> name;
|
||||
@@ -292,7 +293,8 @@ void readRuleset(YAML::Node node, string_array &dest)
|
||||
|
||||
for(unsigned int i = 0; i < node.size(); i++)
|
||||
{
|
||||
name = "";
|
||||
url.clear();
|
||||
name.clear();
|
||||
object = node[i];
|
||||
object["import"] >> name;
|
||||
if(name.size())
|
||||
|
||||
@@ -618,8 +618,14 @@ bool regValid(const std::string &target)
|
||||
jp::Regex reg(target);
|
||||
return !!reg;
|
||||
}
|
||||
|
||||
#endif // USE_STD_REGEX
|
||||
|
||||
std::string regTrim(const std::string &src)
|
||||
{
|
||||
return regReplace(src, "^\\s*?(.*?)\\s*$", "$1");
|
||||
}
|
||||
|
||||
std::string speedCalc(double speed)
|
||||
{
|
||||
if(speed == 0.0)
|
||||
|
||||
@@ -50,6 +50,7 @@ bool regValid(const std::string &target);
|
||||
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);
|
||||
bool regMatch(const std::string &src, const std::string &match);
|
||||
std::string regTrim(const std::string &src);
|
||||
std::string speedCalc(double speed);
|
||||
std::string getMD5(const std::string &data);
|
||||
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))
|
||||
{
|
||||
lineSize = strLine.size();
|
||||
/*
|
||||
if(lineSize && strLine[lineSize - 1] == '\r') //remove line break
|
||||
{
|
||||
strLine.erase(lineSize - 1);
|
||||
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
|
||||
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
|
||||
@@ -542,11 +549,18 @@ void rulesetToSurge(INIReader &base_rule, std::vector<ruleset_content> &ruleset_
|
||||
while(getline(strStrm, strLine, delimiter))
|
||||
{
|
||||
lineSize = strLine.size();
|
||||
/*
|
||||
if(lineSize && strLine[lineSize - 1] == '\r') //remove line break
|
||||
{
|
||||
strLine.erase(lineSize - 1);
|
||||
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
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user