mirror of https://github.com/kiwix/libkiwix.git
Fixed urlEncode() for chars below 0x10
This commit is contained in:
parent
07c7d3931d
commit
e49081da80
|
@ -241,7 +241,8 @@ std::string kiwix::urlEncode(const std::string& value, bool encodeReserved)
|
|||
if (!needsEscape(*it, encodeReserved)) {
|
||||
os << *it;
|
||||
} else {
|
||||
os << '%' << std::setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(*it));
|
||||
const unsigned int charVal = static_cast<unsigned char>(*it);
|
||||
os << '%' << std::setw(2) << std::setfill('0') << charVal;
|
||||
}
|
||||
}
|
||||
return os.str();
|
||||
|
|
|
@ -141,8 +141,7 @@ TEST(stringTools, urlEncode)
|
|||
EXPECT_EQ(urlEncode(otherSymbols), "%60%23%25%5E%5B%5D%7B%7D%5C%7C%22%3C%3E");
|
||||
EXPECT_EQ(urlEncode(otherSymbols), urlEncode(otherSymbols, true));
|
||||
|
||||
// XXX: there is a bug with formatting of single-digit hex values
|
||||
EXPECT_EQ(urlEncode(whitespace), "%20% A% 9% D");
|
||||
EXPECT_EQ(urlEncode(whitespace), "%20%0A%09%0D");
|
||||
EXPECT_EQ(urlEncode(whitespace), urlEncode(whitespace, true));
|
||||
|
||||
EXPECT_EQ(urlEncode(someNonASCIIChars), "%CE%A3%E2%99%82%E2%99%80%E3%83%84");
|
||||
|
|
Loading…
Reference in New Issue