From 835388daf9416157affaa5301e5395fe5e452143 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Mon, 7 Oct 2013 13:10:37 +0200 Subject: [PATCH] cleaner unescapeUrl() --- src/common/kiwix/reader.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/kiwix/reader.cpp b/src/common/kiwix/reader.cpp index 0f7998673..220e12fec 100644 --- a/src/common/kiwix/reader.cpp +++ b/src/common/kiwix/reader.cpp @@ -60,9 +60,10 @@ static char charFromHex(std::string a) { void unescapeUrl(string &url) { std::string::size_type pos = 0; - while ((pos = url.find('%', pos ? pos + 1 : pos)) != std::string::npos && - pos + 3 <= url.length()) { + while ((pos = url.find('%', pos)) != std::string::npos && + pos + 2 < url.length()) { url.replace(pos, 3, 1, charFromHex(url.substr(pos + 1, 2))); + ++pos; } return; }