Skip to content

Commit 946e0dc

Browse files
committed
Fixed bug in function Utils::explode
Decode url before file search
1 parent 4754f75 commit 946e0dc

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/Init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ std::string getClearPath(const std::string &path)
3434

3535
if (std::string::npos == pos)
3636
{
37-
return path;
37+
return Utils::urlDecode(path);
3838
}
3939

40-
return std::string(path.cbegin(), path.cbegin() + pos);
40+
return Utils::urlDecode(path.substr(0, pos) );
4141
}
4242

4343
static void getIncomingVars(std::unordered_multimap<std::string, std::string> &params, const std::string &uri)

src/utils/Utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ namespace Utils
5555

5656
for (size_t pos = 0; std::string::npos != pos;)
5757
{
58-
size_t delimiter = str.find(sep, pos);
58+
const size_t delimiter = str.find(sep, pos);
5959

60-
std::string value = str.substr(pos, delimiter);
60+
std::string value = str.substr(pos, delimiter - pos);
6161
trim(value);
6262

6363
values.emplace_back(std::move(value) );
@@ -865,4 +865,4 @@ namespace Utils
865865

866866
return decoded;
867867
}
868-
};
868+
}

src/utils/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ namespace Utils
137137

138138
std::string urlEncode(const std::string &str);
139139
std::string urlDecode(const std::string &str);
140-
};
140+
}

0 commit comments

Comments
 (0)