Enhancements

Fix request arguments to alias are not passed to redirect location (#681).
Fix crash if name argument is missing in getProfile interface.
Fix bad webGet retry logic.
This commit is contained in:
Tindy X 2023-12-04 11:49:07 +08:00
parent d9ff11146d
commit 2f820b81c4
No known key found for this signature in database
GPG Key ID: 7FA1E66774759718
3 changed files with 16 additions and 4 deletions

View File

@ -1162,13 +1162,13 @@ std::string getProfile(RESPONSE_CALLBACK_ARGS)
std::string name = urlDecode(getUrlArg(argument, "name")), token = urlDecode(getUrlArg(argument, "token"));
string_array profiles = split(name, "|");
name = profiles[0];
if(token.empty() || name.empty())
if(token.empty() || profiles.empty())
{
*status_code = 403;
return "Forbidden";
}
std::string profile_content;
name = profiles[0];
/*if(vfs::vfs_exist(name))
{
profile_content = vfs::vfs_get(name);

View File

@ -252,7 +252,7 @@ static int curlGet(const FetchArgument &argument, FetchResult &result)
while(true)
{
retVal = curl_easy_perform(curl_handle);
if(retVal == CURLE_OK || max_fails >= fail_count)
if(retVal == CURLE_OK || max_fails <= fail_count)
break;
else
fail_count++;

View File

@ -155,7 +155,19 @@ int WebServer::start_web_server_multi(listener_args *args)
for (auto &x : redirect_map)
{
server.Get(x.first, [x](const httplib::Request &req, httplib::Response &res) {
res.set_redirect(x.second);
auto arguments = req.params;
auto query = x.second;
auto pos = query.find('?');
query += pos == std::string::npos ? '?' : '&';
for (auto &p: arguments)
{
query += p.first + "=" + urlEncode(p.second) + "&";
}
if (!query.empty())
{
query.pop_back();
}
res.set_redirect(query);
});
}
server.set_exception_handler([](const httplib::Request &req, httplib::Response &res, const std::exception_ptr &e)