mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-03 18:24:58 +00:00
Enhancements
Fix request parameters are url-decoded twice. Fix post form request not handled correctly.
This commit is contained in:
4 files changed
+14
-14
No files matched your search
@@ -331,12 +331,12 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
readConf();
|
readConf();
|
||||||
|
|
||||||
/// string values
|
/// string values
|
||||||
std::string argUrl = urlDecode(getUrlArg(argument, "url"));
|
std::string argUrl = getUrlArg(argument, "url");
|
||||||
std::string argGroupName = urlDecode(getUrlArg(argument, "group")), argUploadPath = getUrlArg(argument, "upload_path");
|
std::string argGroupName = getUrlArg(argument, "group"), argUploadPath = getUrlArg(argument, "upload_path");
|
||||||
std::string argIncludeRemark = urlDecode(getUrlArg(argument, "include")), argExcludeRemark = urlDecode(getUrlArg(argument, "exclude"));
|
std::string argIncludeRemark = getUrlArg(argument, "include"), argExcludeRemark = getUrlArg(argument, "exclude");
|
||||||
std::string argCustomGroups = urlSafeBase64Decode(getUrlArg(argument, "groups")), argCustomRulesets = urlSafeBase64Decode(getUrlArg(argument, "ruleset")), argExternalConfig = urlDecode(getUrlArg(argument, "config"));
|
std::string argCustomGroups = urlSafeBase64Decode(getUrlArg(argument, "groups")), argCustomRulesets = urlSafeBase64Decode(getUrlArg(argument, "ruleset")), argExternalConfig = getUrlArg(argument, "config");
|
||||||
std::string argDeviceID = getUrlArg(argument, "dev_id"), argFilename = urlDecode(getUrlArg(argument, "filename")), argUpdateInterval = getUrlArg(argument, "interval"), argUpdateStrict = getUrlArg(argument, "strict");
|
std::string argDeviceID = getUrlArg(argument, "dev_id"), argFilename = getUrlArg(argument, "filename"), argUpdateInterval = getUrlArg(argument, "interval"), argUpdateStrict = getUrlArg(argument, "strict");
|
||||||
std::string argRenames = urlDecode(getUrlArg(argument, "rename")), argFilterScript = urlDecode(getUrlArg(argument, "filter_script"));
|
std::string argRenames = getUrlArg(argument, "rename"), argFilterScript = getUrlArg(argument, "filter_script");
|
||||||
|
|
||||||
/// switches with default value
|
/// switches with default value
|
||||||
tribool argUpload = getUrlArg(argument, "upload"), argEmoji = getUrlArg(argument, "emoji"), argAddEmoji = getUrlArg(argument, "add_emoji"), argRemoveEmoji = getUrlArg(argument, "remove_emoji");
|
tribool argUpload = getUrlArg(argument, "upload"), argEmoji = getUrlArg(argument, "emoji"), argAddEmoji = getUrlArg(argument, "add_emoji"), argRemoveEmoji = getUrlArg(argument, "remove_emoji");
|
||||||
@@ -701,7 +701,7 @@ std::string subconverter(RESPONSE_CALLBACK_ARGS)
|
|||||||
|
|
||||||
ProxyGroupConfigs dummy_group;
|
ProxyGroupConfigs dummy_group;
|
||||||
std::vector<RulesetContent> dummy_ruleset;
|
std::vector<RulesetContent> dummy_ruleset;
|
||||||
std::string managed_url = base64Decode(urlDecode(getUrlArg(argument, "profile_data")));
|
std::string managed_url = base64Decode(getUrlArg(argument, "profile_data"));
|
||||||
if(managed_url.empty())
|
if(managed_url.empty())
|
||||||
managed_url = global.managedConfigPrefix + "/sub?" + joinArguments(argument);
|
managed_url = global.managedConfigPrefix + "/sub?" + joinArguments(argument);
|
||||||
|
|
||||||
@@ -1160,7 +1160,7 @@ std::string getProfile(RESPONSE_CALLBACK_ARGS)
|
|||||||
auto &argument = request.argument;
|
auto &argument = request.argument;
|
||||||
int *status_code = &response.status_code;
|
int *status_code = &response.status_code;
|
||||||
|
|
||||||
std::string name = urlDecode(getUrlArg(argument, "name")), token = urlDecode(getUrlArg(argument, "token"));
|
std::string name = getUrlArg(argument, "name"), token = getUrlArg(argument, "token");
|
||||||
string_array profiles = split(name, "|");
|
string_array profiles = split(name, "|");
|
||||||
if(token.empty() || profiles.empty())
|
if(token.empty() || profiles.empty())
|
||||||
{
|
{
|
||||||
@@ -1440,7 +1440,7 @@ std::string renderTemplate(RESPONSE_CALLBACK_ARGS)
|
|||||||
auto &argument = request.argument;
|
auto &argument = request.argument;
|
||||||
int *status_code = &response.status_code;
|
int *status_code = &response.status_code;
|
||||||
|
|
||||||
std::string path = urlDecode(getUrlArg(argument, "path"));
|
std::string path = getUrlArg(argument, "path");
|
||||||
writeLog(0, "Trying to render template '" + path + "'...", LOG_LEVEL_INFO);
|
writeLog(0, "Trying to render template '" + path + "'...", LOG_LEVEL_INFO);
|
||||||
|
|
||||||
if(!startsWith(path, global.templatePath) || !fileExist(path))
|
if(!startsWith(path, global.templatePath) || !fileExist(path))
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ static httplib::Server::Handler makeHandler(const responseRoute &rr)
|
|||||||
req.argument = request.params;
|
req.argument = request.params;
|
||||||
if (request.get_header_value("Content-Type") == "application/x-www-form-urlencoded")
|
if (request.get_header_value("Content-Type") == "application/x-www-form-urlencoded")
|
||||||
{
|
{
|
||||||
req.postdata = urlDecode(req.postdata);
|
req.postdata = urlDecode(request.body);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -343,10 +343,10 @@ std::string getUrlArg(const std::string &url, const std::string &request)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getUrlArg(const string_multimap &url, const std::string &request)
|
std::string getUrlArg(const string_multimap &args, const std::string &request)
|
||||||
{
|
{
|
||||||
auto it = url.find(request);
|
auto it = args.find(request);
|
||||||
if(it != url.end())
|
if(it != args.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ std::string join(InputIt first, InputIt last, const std::string &delimiter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string getUrlArg(const std::string &url, const std::string &request);
|
std::string getUrlArg(const std::string &url, const std::string &request);
|
||||||
std::string getUrlArg(const string_multimap &url, const std::string &request);
|
std::string getUrlArg(const string_multimap &args, const std::string &request);
|
||||||
std::string replaceAllDistinct(std::string str, const std::string &old_value, const std::string &new_value);
|
std::string replaceAllDistinct(std::string str, const std::string &old_value, const std::string &new_value);
|
||||||
std::string trimOf(const std::string& str, char target, bool before = true, bool after = true);
|
std::string trimOf(const std::string& str, char target, bool before = true, bool after = true);
|
||||||
std::string trim(const std::string& str, bool before = true, bool after = true);
|
std::string trim(const std::string& str, bool before = true, bool after = true);
|
||||||
|
|||||||
Reference in new issue
Block a user