Skip to content

Commit

Permalink
Merge pull request NixOS#11349 from bryanhonof/bryanhonof.check-query…
Browse files Browse the repository at this point in the history
…-for-equals

Warn on malformed URI query parameter
  • Loading branch information
roberth authored Aug 28, 2024
2 parents cb4b9be + 9b1cefe commit b89eca9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/libutil/url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ 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("dubious URI query '%s' is missing equal sign '%s'", s, "=");
continue;
}

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

return result;
Expand Down

0 comments on commit b89eca9

Please sign in to comment.