mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 02:36:16 +02:00
fix: warn on malformed URI query parameter
This commit is contained in:
parent
0ed67e5b7e
commit
1f024ecfcd
2 changed files with 9 additions and 5 deletions
|
@ -88,7 +88,7 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
|
||||||
if (fragmentStart != std::string::npos) {
|
if (fragmentStart != std::string::npos) {
|
||||||
fragment = percentDecode(url.substr(fragmentStart+1));
|
fragment = percentDecode(url.substr(fragmentStart+1));
|
||||||
}
|
}
|
||||||
if (pathEnd != std::string::npos && fragmentStart != std::string::npos) {
|
if (pathEnd != std::string::npos && fragmentStart != std::string::npos && url[pathEnd] == '?') {
|
||||||
query = decodeQuery(url.substr(pathEnd+1, fragmentStart-pathEnd-1));
|
query = decodeQuery(url.substr(pathEnd+1, fragmentStart-pathEnd-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,11 @@ 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("dubious URI query '%s' is missing equal sign '%s', ignoring", 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)));
|
||||||
|
|
Loading…
Reference in a new issue