mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-29 21:03:00 +00:00
Enhancements
Add validation of exclude/include values passed from URI argument. Update pref.ini.
This commit is contained in:
4
main.cpp
4
main.cpp
@@ -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;
|
||||
|
||||
13
misc.cpp
13
misc.cpp
@@ -438,6 +438,19 @@ std::string replace_all_distinct(std::string str, std::string old_value, std::st
|
||||
return str;
|
||||
}
|
||||
|
||||
bool regValid(std::string ®)
|
||||
{
|
||||
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
1
misc.h
@@ -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 ®);
|
||||
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);
|
||||
|
||||
5
pref.ini
5
pref.ini
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user