Skip to content

Commit

Permalink
Some clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
veloman-yunkan committed Jan 25, 2023
1 parent 43d57b2 commit 125a576
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/tools/stringTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,6 @@ bool isHarmlessUriChar(char c)
return false;
}

bool needsEscape(char c, bool encodeReserved)
{
if (isHarmlessUriChar(c))
return false;

if (isReservedUrlChar(c))
return encodeReserved;

return true;
}

int hexToInt(char c) {
switch (c) {
case '0': return 0;
Expand Down Expand Up @@ -247,14 +236,11 @@ std::string kiwix::urlEncode(const std::string& value)
{
std::ostringstream os;
os << std::hex << std::uppercase;
for (std::string::const_iterator it = value.begin();
it != value.end();
it++) {

if (!needsEscape(*it, true)) {
os << *it;
for (const char c : value) {
if (isHarmlessUriChar(c)) {
os << c;
} 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;
}
}
Expand Down

0 comments on commit 125a576

Please sign in to comment.