fix: Error on malformed URI query parameter

Signed-off-by: Bryan Honof <bryanhonof@gmail.com>
This commit is contained in:
Bryan Honof 2024-08-21 16:57:06 +02:00
parent 85f1aa6b3d
commit c9f45677b5
No known key found for this signature in database

View file

@ -79,7 +79,12 @@ std::map<std::string, std::string> decodeQuery(const std::string & query)
for (auto s : tokenizeString<Strings>(query, "&")) { for (auto s : tokenizeString<Strings>(query, "&")) {
auto e = s.find('='); auto e = s.find('=');
if (e != std::string::npos)
if (e == std::string::npos) {
warn("invalid URI query '%s', did you forget an equals sign `=`?", s);
continue;
}
result.emplace( result.emplace(
s.substr(0, e), s.substr(0, e),
percentDecode(std::string_view(s).substr(e + 1))); percentDecode(std::string_view(s).substr(e + 1)));