Skip to content

Commit

Permalink
fix: Error on malformed URI query parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Bryan Honof <bryanhonof@gmail.com>
  • Loading branch information
bryanhonof committed Aug 21, 2024
1 parent af26fe3 commit e7eb55b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/libutil/url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,13 @@ std::map<std::string, std::string> decodeQuery(const std::string & query)

for (auto s : tokenizeString<Strings>(query, "&")) {
auto e = s.find('=');
if (e != std::string::npos)
result.emplace(
s.substr(0, e),
percentDecode(std::string_view(s).substr(e + 1)));

if (e == std::string::npos)
warn("invalid URI query '%s', did you forget an equals sign `=`?", s);

result.emplace(
s.substr(0, e),
percentDecode(std::string_view(s).substr(e + 1)));
}

return result;
Expand Down

0 comments on commit e7eb55b

Please sign in to comment.