This commit is contained in:
jomjol
2023-02-18 11:44:56 +01:00
parent 7283bfd506
commit 008dba7e11
4 changed files with 43 additions and 10 deletions

View File

@@ -898,3 +898,33 @@ const char* get404(void) {
" You could try your <a href=index.html target=_parent>luck</a> here!</pre>\n"
"<script>document.cookie = \"page=overview.html\"</script>"; // Make sure we load the overview page
}
std::string UrlDecode(const std::string& value)
{
std::string result;
result.reserve(value.size());
for (std::size_t i = 0; i < value.size(); ++i)
{
auto ch = value[i];
if (ch == '%' && (i + 2) < value.size())
{
auto hex = value.substr(i + 1, 2);
auto dec = static_cast<char>(std::strtol(hex.c_str(), nullptr, 16));
result.push_back(dec);
i += 2;
}
else if (ch == '+')
{
result.push_back(' ');
}
else
{
result.push_back(ch);
}
}
return result;
}

View File

@@ -93,4 +93,7 @@ std::string getFormatedUptime(bool compact);
const char* get404(void);
std::string UrlDecode(const std::string& value);
#endif //HELPER_H