diff --git a/src/util/StringUtil.cc b/src/util/StringUtil.cc index fe69bce002..c039a73211 100644 --- a/src/util/StringUtil.cc +++ b/src/util/StringUtil.cc @@ -92,13 +92,17 @@ std::string StringUtil::url_encode(const std::string& str) while (cur < end) { - if (*cur == ' ') - res += '+'; - else if (isalnum(*cur) || *cur == '-' || *cur == '_' || *cur == '.' || - *cur == '!' || *cur == '~' || *cur == '*' || *cur == '\'' || - *cur == '(' || *cur == ')' || *cur == ':' || *cur == '/' || - *cur == '@' || *cur == '?' || *cur == '#' || *cur == '&') + if (isalnum(*cur) || *cur == '-' || *cur == '_' || *cur == '.' || + *cur == '!' || *cur == '~' || *cur == '*' || *cur == '\'' || + *cur == '(' || *cur == ')' || *cur == ':' || *cur == '/' || + *cur == '@' || *cur == '?' || *cur == '#' || *cur == '&') + { res += *cur; + } + else if (*cur == ' ') + { + res += '+'; + } else { res += '%'; @@ -120,12 +124,16 @@ std::string StringUtil::url_encode_component(const std::string& str) while (cur < end) { - if (*cur == ' ') - res += '+'; - else if (isalnum(*cur) || *cur == '-' || *cur == '_' || *cur == '.' || - *cur == '!' || *cur == '~' || *cur == '*' || *cur == '\'' || - *cur == '(' || *cur == ')') + if (isalnum(*cur) || *cur == '-' || *cur == '_' || *cur == '.' || + *cur == '!' || *cur == '~' || *cur == '*' || *cur == '\'' || + *cur == '(' || *cur == ')') + { res += *cur; + } + else if (*cur == ' ') + { + res += '+'; + } else { res += '%';