Skip to content

Commit 8791f72

Browse files
committed
fix url escape/unescape
1 parent 97c88bd commit 8791f72

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

net/http/url.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ std::string url_escape(std::string_view url, bool escape_slash) {
108108
std::string ret;
109109
ret.reserve(url.size() * 2);
110110

111-
for (auto c : url) {
111+
for (unsigned char c : url) {
112112
if (isunreserved(c)) {
113113
ret.push_back(c);
114114
} else if (!escape_slash && c == '/') {
@@ -126,7 +126,7 @@ std::string url_unescape(std::string_view url) {
126126
std::string ret;
127127
ret.reserve(url.size());
128128
for (unsigned int i = 0; i < url.size(); i++) {
129-
if (url[i] == '%') {
129+
if (url[i] == '%' && i + 2 < url.size()) {
130130
auto c = estring_view(url.substr(i + 1, 2)).hex_to_uint64();
131131
ret += static_cast<char>(c);
132132
i += 2;

0 commit comments

Comments
 (0)