mirror of https://github.com/kiwix/libkiwix.git
Some clean-up
This commit is contained in:
parent
471c5b89f4
commit
ca079a72cc
|
@ -208,17 +208,6 @@ bool isHarmlessUriChar(char c)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needsEscape(char c, bool encodeReserved)
|
|
||||||
{
|
|
||||||
if (isHarmlessUriChar(c))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (isReservedUrlChar(c))
|
|
||||||
return encodeReserved;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int hexToInt(char c) {
|
int hexToInt(char c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '0': return 0;
|
case '0': return 0;
|
||||||
|
@ -247,14 +236,11 @@ std::string kiwix::urlEncode(const std::string& value)
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << std::hex << std::uppercase;
|
os << std::hex << std::uppercase;
|
||||||
for (std::string::const_iterator it = value.begin();
|
for (const char c : value) {
|
||||||
it != value.end();
|
if (isHarmlessUriChar(c)) {
|
||||||
it++) {
|
os << c;
|
||||||
|
|
||||||
if (!needsEscape(*it, true)) {
|
|
||||||
os << *it;
|
|
||||||
} else {
|
} else {
|
||||||
const unsigned int charVal = static_cast<unsigned char>(*it);
|
const unsigned int charVal = static_cast<unsigned char>(c);
|
||||||
os << '%' << std::setw(2) << std::setfill('0') << charVal;
|
os << '%' << std::setw(2) << std::setfill('0') << charVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue