Merge "libutil: fix non-ASCII chars in URL encoding" into main
This commit is contained in:
commit
8a9094303b
|
@ -104,7 +104,7 @@ std::string percentEncode(std::string_view s, std::string_view keep)
|
|||
|| keep.find(c) != std::string::npos)
|
||||
res += c;
|
||||
else
|
||||
res += fmt("%%%02X", (unsigned int) c);
|
||||
res += fmt("%%%02X", 0xff & (unsigned int) c);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -303,7 +303,6 @@ namespace nix {
|
|||
ASSERT_EQ(d, s);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* percentEncode
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
@ -336,4 +335,10 @@ namespace nix {
|
|||
ASSERT_EQ(d, s);
|
||||
}
|
||||
|
||||
TEST(percentEncode, utf8Input) {
|
||||
std::string s = percentEncode("ä");
|
||||
std::string d = "%C3%A4";
|
||||
|
||||
ASSERT_EQ(d, s);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue