Skip to content

Commit 7d1f6f2

Browse files
authored
Merge pull request #69 from jackjansen/fix-urldecode-plus
Also replace + by space in urlDecode
2 parents f9513ac + aa3ff70 commit 7d1f6f2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/util.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,14 @@ std::string intToString(int i) {
6161

6262
std::string urlDecode(std::string input) {
6363
std::size_t idxReplaced = 0;
64-
std::size_t idxFound = input.find('%');
64+
// First replace + by space
65+
std::size_t idxFound = input.find('+');
66+
while (idxFound != std::string::npos) {
67+
input.replace(idxFound, 1, 1, ' ');
68+
idxFound = input.find('+', idxFound + 1);
69+
}
70+
// Now replace percent-escapes
71+
idxFound = input.find('%');
6572
while (idxFound != std::string::npos) {
6673
if (idxFound <= input.length() + 3) {
6774
char hex[2] = { input[idxFound+1], input[idxFound+2] };

0 commit comments

Comments
 (0)