diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2018-04-05 21:49:44 +0200 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2018-04-05 21:49:44 +0200 |
commit | 1fc85b87bd0542b82b1a8d51afdb3801d03d872b (patch) | |
tree | b4503f2af3838dab45f81e9683736af9dd0501d8 | |
parent | 8d8e9d54c859625277c7de977b361165c09b06b1 (diff) |
Fix buggy percent-encoding
Fixes #17875.
-rw-r--r-- | core/ustring.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 97fffc0668..d749146998 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3168,8 +3168,8 @@ String String::word_wrap(int p_chars_per_line) const { String String::percent_encode() 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::percent_encode() 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; |