Fix buggy http-encoding

(cherry picked from commit 1fc85b87bd)

The original commit's message said "percent-encoding" because it was fixing the same code under a different method name. That rename was reverted but the fix was and is still relevant.
This commit is contained in:
Pedro J. Estébanez 2018-04-05 21:49:44 +02:00
parent 46101928bd
commit a9ec1e3913
1 changed files with 4 additions and 4 deletions

View File

@ -3168,8 +3168,8 @@ String String::word_wrap(int p_chars_per_line) const {
String String::http_escape() const {
const CharString temp = utf8();
String res;
for (int i = 0; i < length(); ++i) {
CharType ord = temp[i];
for (int i = 0; i < temp.length(); ++i) {
char ord = temp[i];
if (ord == '.' || ord == '-' || ord == '_' || ord == '~' ||
(ord >= 'a' && ord <= 'z') ||
(ord >= 'A' && ord <= 'Z') ||
@ -3178,9 +3178,9 @@ String String::http_escape() const {
} else {
char h_Val[3];
#if defined(__GNUC__) || defined(_MSC_VER)
snprintf(h_Val, 3, "%.2X", ord);
snprintf(h_Val, 3, "%hhX", ord);
#else
sprintf(h_Val, "%.2X", ord);
sprintf(h_Val, "%hhX", ord);
#endif
res += "%";
res += h_Val;