+ fix escaping character (%) parser in url parsing

This commit is contained in:
kelson42 2013-08-05 16:40:40 +08:00
parent 5d8593805f
commit 58f30fd0e5
1 changed files with 4 additions and 5 deletions

View File

@ -27,11 +27,10 @@ static char charFromHex(std::string a) {
}
void unescapeUrl(string &url) {
std::string::size_type pos;
std::string hex;
while (std::string::npos != (pos = url.find('%'))) {
hex = url.substr(pos + 1, 2);
url.replace(pos, 3, 1, charFromHex(hex));
std::string::size_type pos = 0;
while ((pos = url.find('%', pos + 1)) != std::string::npos &&
pos + 3 <= url.length()) {
url.replace(pos, 3, 1, charFromHex(url.substr(pos + 1, 2)));
}
return;
}