mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-28 12:22:37 +00:00
Enhancements
Fix missing keys and sections in Mellow configs. Fix Emoji matching rules. Add token verification when using default_urls in API mode. Optimize codes.
This commit is contained in:
@@ -13,7 +13,7 @@ ES,🇪🇸
|
||||
EU,🇪🇺
|
||||
(Finland|芬兰|赫尔辛基),🇫🇮
|
||||
(FR|France|法国|巴黎),🇫🇷
|
||||
(?i:UK|England|United.*?Kingdom|[^-]英|伦敦),🇬🇧
|
||||
(?i:UK|England|United.*?Kingdom|英国|[^-]英|伦敦),🇬🇧
|
||||
(?i:HK|Hong.*?Kong|HKT|HKBN|HGC|WTT|CMI|[^-]港),🇭🇰
|
||||
(Indonesia|印尼|印度尼西亚|雅加达),🇮🇩
|
||||
(Ireland|爱尔兰|都柏林),🇮🇪
|
||||
@@ -27,14 +27,14 @@ EU,🇪🇺
|
||||
(NL|Netherlands|荷兰|阿姆斯特丹),🇳🇱
|
||||
(PH|Philippines|菲律宾),🇵🇭
|
||||
(RO|罗马尼亚),🇷🇴
|
||||
(RU|Russia|伯力|莫斯科|圣彼得堡|西伯利亚|新西伯利亚|[^-]俄),🇷🇺
|
||||
(RU|Russia|伯力|莫斯科|圣彼得堡|西伯利亚|新西伯利亚|俄罗斯|[^-]俄),🇷🇺
|
||||
(沙特|迪拜),🇸🇦
|
||||
(SE|Sweden),🇸🇪
|
||||
(SG|Singapore|新加坡|狮城|[^-]新),🇸🇬
|
||||
(TH|Thailand|泰国|曼谷),🇹🇭
|
||||
(TR|Turkey|土耳其|伊斯坦布尔),🇹🇷
|
||||
(?i:US|America|United.*?States|[^-]美|波特兰|达拉斯|俄勒冈|凤凰城|费利蒙|硅谷|拉斯维加斯|洛杉矶|圣何塞|圣克拉拉|西雅图|芝加哥),🇺🇲
|
||||
(?i:US|America|United.*?States|美国|[^-]美|波特兰|达拉斯|俄勒冈|凤凰城|费利蒙|硅谷|拉斯维加斯|洛杉矶|圣何塞|圣克拉拉|西雅图|芝加哥),🇺🇲
|
||||
(VN|越南),🇻🇳
|
||||
(ZA|南非),🇿🇦
|
||||
(?i:TW|Taiwan|新北|彰化|CHT|新北|[^-]台|HINET),🇨🇳
|
||||
(?i:TW|Taiwan|新北|彰化|CHT|台湾|[^-]台|HINET),🇨🇳
|
||||
(?i:CN|China|回国|中国|江苏|北京|上海|广州|深圳|杭州|徐州|青岛|宁波|镇江|back),🇨🇳
|
||||
|
||||
@@ -168,6 +168,7 @@ public:
|
||||
exclude_sections = src.exclude_sections;
|
||||
include_sections = src.include_sections;
|
||||
read_sections = src.read_sections;
|
||||
section_order = src.section_order;
|
||||
isolated_items_section = src.isolated_items_section;
|
||||
//copy preferences
|
||||
do_utf8_to_gbk = src.do_utf8_to_gbk;
|
||||
|
||||
@@ -777,11 +777,13 @@ void generateBase()
|
||||
base_content = fileGet(mellow_rule_base, false);
|
||||
else
|
||||
base_content = webGet(mellow_rule_base, getSystemProxy());
|
||||
mellow_base.keep_empty_section = true;
|
||||
mellow_base.store_any_line = true;
|
||||
retVal = mellow_base.Parse(base_content);
|
||||
if(retVal != INIREADER_EXCEPTION_NONE)
|
||||
std::cerr<<"Unable to load Mellow base content. Reason: "<<mellow_base.GetLastError()<<"\n";
|
||||
else
|
||||
rulesetToSurge(mellow_base, ruleset_content_array, 2, overwrite_original_rules);
|
||||
rulesetToSurge(mellow_base, ruleset_content_array, 0, overwrite_original_rules);
|
||||
}
|
||||
|
||||
std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
@@ -790,7 +792,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
std::string group = UrlDecode(getUrlArg(argument, "group")), upload = getUrlArg(argument, "upload"), upload_path = getUrlArg(argument, "upload_path"), version = getUrlArg(argument, "ver");
|
||||
std::string append_type = getUrlArg(argument, "append_type"), tfo = getUrlArg(argument, "tfo"), udp = getUrlArg(argument, "udp"), nodelist = getUrlArg(argument, "list");
|
||||
std::string include = UrlDecode(getUrlArg(argument, "include")), exclude = UrlDecode(getUrlArg(argument, "exclude")), sort_flag = getUrlArg(argument, "sort");
|
||||
std::string scv = getUrlArg(argument, "scv"), fdn = getUrlArg(argument, "fdn");
|
||||
std::string scv = getUrlArg(argument, "scv"), fdn = getUrlArg(argument, "fdn"), token = getUrlArg(argument, "token");
|
||||
std::string base_content, output_content;
|
||||
string_array extra_group, extra_ruleset, include_remarks, exclude_remarks;
|
||||
std::string groups = urlsafe_base64_decode(getUrlArg(argument, "groups")), ruleset = urlsafe_base64_decode(getUrlArg(argument, "ruleset")), config = UrlDecode(getUrlArg(argument, "config"));
|
||||
@@ -807,7 +809,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
||||
std::string ext_quan_base = quan_rule_base, ext_quanx_base = quanx_rule_base;
|
||||
|
||||
//validate urls
|
||||
if(!url.size())
|
||||
if(!url.size() && (!api_mode || token == access_token))
|
||||
url = default_url;
|
||||
if(!url.size() || !target.size())
|
||||
{
|
||||
@@ -1149,7 +1151,7 @@ std::string simpleToClashR(RESPONSE_CALLBACK_ARGS)
|
||||
std::vector<ruleset_content> rca;
|
||||
std::string subInfo;
|
||||
|
||||
if(!url.size())
|
||||
if(!url.size() && !api_mode)
|
||||
url = default_url;
|
||||
if(!url.size() || argument.substr(0, 8) != "sublink=")
|
||||
{
|
||||
|
||||
14
src/misc.cpp
14
src/misc.cpp
@@ -669,7 +669,7 @@ std::string fileGet(std::string path, bool binary, bool scope_limit)
|
||||
if(scope_limit)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if(path.find(":/") != path.npos || path.find("..") != path.npos)
|
||||
if(path.find(":\\") != path.npos || path.find("..") != path.npos)
|
||||
return std::string();
|
||||
#else
|
||||
if(path.find("/") == 0 || path.find("..") != path.npos)
|
||||
@@ -916,11 +916,8 @@ std::string getFormData(const std::string &raw_data)
|
||||
std::string line;
|
||||
|
||||
std::string boundary;
|
||||
std::string disp; /* content disposition string */
|
||||
std::string type; /* content type string */
|
||||
std::string file; /* actual file content */
|
||||
|
||||
|
||||
int i = 0;
|
||||
|
||||
strstrm<<raw_data;
|
||||
@@ -932,18 +929,9 @@ std::string getFormData(const std::string &raw_data)
|
||||
// Get boundary
|
||||
boundary = line.substr(0, line.length() - 1);
|
||||
}
|
||||
else if(line.find("Content-Disposition") == 0)
|
||||
{
|
||||
disp = line;
|
||||
}
|
||||
else if(line.find("Content-Type") == 0)
|
||||
{
|
||||
type = line;
|
||||
}
|
||||
else if(line.find(boundary) == 0)
|
||||
{
|
||||
// The end
|
||||
type = line;
|
||||
break;
|
||||
}
|
||||
else if(line.length() == 1)
|
||||
|
||||
Reference in New Issue
Block a user