utils: urldecode: Fix bounds check

Sigh...
This commit is contained in:
2025-11-03 18:13:08 +01:00
parent 227bc438ed
commit a31d88c7b3

View File

@@ -63,11 +63,12 @@ std::string utils::html_xss(std::string_view str)
std::string utils::urldecode(std::string_view str) std::string utils::urldecode(std::string_view str)
{ {
std::string result; std::string result;
int size = str.length(); size_t size = str.length();
for(int i = 0; i < size; i++) for(size_t i = 0; i < size; i++)
{ {
char c = str[i]; char c = str[i];
if(c == '%' && (size - i > 1))
if(c == '%' && i + 2 < size)
{ {
char h[3]; char h[3];
h[0] = str[i + 1]; h[0] = str[i + 1];