mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-03 02:02:24 +00:00
Enhancements
Add authorization check before loading scripts. Add detailed logs when loading preference settings.
This commit is contained in:
6 files changed
+17
-12
No files matched your search
@@ -51,7 +51,7 @@ int addNodes(std::string link, std::vector<Proxy> &allNodes, int groupID, parse_
|
||||
link = replaceAllDistinct(link, "\"", "");
|
||||
|
||||
/// script:filepath,arg1,arg2,...
|
||||
script_safe_runner(parse_set.js_runtime, parse_set.js_context, [&](qjs::Context &ctx)
|
||||
if(authorized) script_safe_runner(parse_set.js_runtime, parse_set.js_context, [&](qjs::Context &ctx)
|
||||
{
|
||||
if(startsWith(link, "script:")) /// process subscription with script
|
||||
{
|
||||
@@ -380,7 +380,7 @@ void nodeRename(Proxy &node, const RegexMatchConfigs &rename_array, extra_settin
|
||||
|
||||
for(const RegexMatchConfig &x : rename_array)
|
||||
{
|
||||
if(!x.Script.empty())
|
||||
if(!x.Script.empty() && ext.authorized)
|
||||
{
|
||||
script_safe_runner(ext.js_runtime, ext.js_context, [&](qjs::Context &ctx)
|
||||
{
|
||||
@@ -432,7 +432,7 @@ std::string addEmoji(const Proxy &node, const RegexMatchConfigs &emoji_array, ex
|
||||
|
||||
for(const RegexMatchConfig &x : emoji_array)
|
||||
{
|
||||
if(!x.Script.empty())
|
||||
if(!x.Script.empty() && ext.authorized)
|
||||
{
|
||||
std::string result;
|
||||
script_safe_runner(ext.js_runtime, ext.js_context, [&](qjs::Context &ctx)
|
||||
@@ -481,7 +481,7 @@ void preprocessNodes(std::vector<Proxy> &nodes, extra_settings &ext)
|
||||
if(ext.sort_flag)
|
||||
{
|
||||
bool failed = true;
|
||||
if(ext.sort_script.size())
|
||||
if(ext.sort_script.size() && ext.authorized)
|
||||
{
|
||||
std::string script = ext.sort_script;
|
||||
if(startsWith(script, "path:"))
|
||||
|
||||
@@ -183,7 +183,7 @@ void groupGenerate(const std::string &rule, std::vector<Proxy> &nodelist, string
|
||||
filtered_nodelist.emplace_back(rule.substr(2));
|
||||
}
|
||||
#ifndef NO_JS_RUNTIME
|
||||
else if(startsWith(rule, "script:"))
|
||||
else if(startsWith(rule, "script:") && ext.authorized)
|
||||
{
|
||||
script_safe_runner(ext.js_runtime, ext.js_context, [&](qjs::Context &ctx){
|
||||
std::string script = fileGet(rule.substr(7), true);
|
||||
|
||||
@@ -39,6 +39,7 @@ struct extra_settings
|
||||
bool clash_classical_ruleset = false;
|
||||
std::string sort_script = "";
|
||||
std::string clash_proxies_style = "flow";
|
||||
bool authorized = false;
|
||||
|
||||
extra_settings() {};
|
||||
extra_settings(const extra_settings&) = delete;
|
||||
|
||||
Reference in new issue
Block a user