Enhancements

Add validation of exclude/include values passed from URI argument.
Update pref.ini.
This commit is contained in:
Tindy X
2019-12-03 22:00:00 +08:00
parent 4057d7e216
commit 6079487fde
4 changed files with 20 additions and 3 deletions

View File

@@ -303,11 +303,11 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
std::vector<nodeInfo> nodes;
int groupID = 0;
if(include.size())
if(include.size() && regValid(include))
include_remarks.emplace_back(include);
else
include_remarks = def_include_remarks;
if(exclude.size())
if(exclude.size() && regValid(exclude))
exclude_remarks.emplace_back(exclude);
else
exclude_remarks = def_exclude_remarks;

View File

@@ -438,6 +438,19 @@ std::string replace_all_distinct(std::string str, std::string old_value, std::st
return str;
}
bool regValid(std::string &reg)
{
try
{
std::regex r(reg);
return true;
}
catch (std::regex_error &e)
{
return false;
}
}
bool regFind(std::string src, std::string target)
{
try

1
misc.h
View File

@@ -40,6 +40,7 @@ bool is_str_utf8(std::string data);
std::string getFormData(const std::string &raw_data);
void sleep(int interval);
bool regValid(std::string &reg);
bool regFind(std::string src, std::string target);
std::string regReplace(std::string src, std::string match, std::string rep);
bool regMatch(std::string src, std::string match);

View File

@@ -6,7 +6,7 @@ api_mode=false
default_url=
;Exclude nodes which remarks match the following patterns. Supports regular expression.
exclude_remarks=(流量|时间|官网|产品)
exclude_remarks=(到期|流量|时间|官网|产品)
;exclude_remarks=(other rule)
;Only include nodes which remarks match the following patterns. Supports regular expression.
@@ -93,6 +93,9 @@ write_managed_config=true
;Address prefix for MANAGED-CONFIG info, without the trailing "/".
managed_config_prefix=http://127.0.0.1:25500
[surge_external_proxy]
;surge_ssr_path=/usr/bin/ssr-local
[emojis]
add_emoji=true
remove_old_emoji=true