[Pseudolocalization] Prevent out of bounds reads.

(cherry picked from commit e7bdb60e56)
This commit is contained in:
bruvzg 2024-01-05 14:05:16 +02:00 committed by Rémi Verschelde
parent 7691c5fccd
commit e35e97f027
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 5 additions and 5 deletions

View File

@ -881,7 +881,7 @@ StringName TranslationServer::tool_pseudolocalize(const StringName &p_message) c
String TranslationServer::get_override_string(String &p_message) const {
String res;
for (int i = 0; i < p_message.size(); i++) {
for (int i = 0; i < p_message.length(); i++) {
if (pseudolocalization_skip_placeholders_enabled && is_placeholder(p_message, i)) {
res += p_message[i];
res += p_message[i + 1];
@ -895,7 +895,7 @@ String TranslationServer::get_override_string(String &p_message) const {
String TranslationServer::double_vowels(String &p_message) const {
String res;
for (int i = 0; i < p_message.size(); i++) {
for (int i = 0; i < p_message.length(); i++) {
if (pseudolocalization_skip_placeholders_enabled && is_placeholder(p_message, i)) {
res += p_message[i];
res += p_message[i + 1];
@ -913,7 +913,7 @@ String TranslationServer::double_vowels(String &p_message) const {
String TranslationServer::replace_with_accented_string(String &p_message) const {
String res;
for (int i = 0; i < p_message.size(); i++) {
for (int i = 0; i < p_message.length(); i++) {
if (pseudolocalization_skip_placeholders_enabled && is_placeholder(p_message, i)) {
res += p_message[i];
res += p_message[i + 1];
@ -936,7 +936,7 @@ String TranslationServer::wrap_with_fakebidi_characters(String &p_message) const
char32_t fakebidisuffix = U'\u202c';
res += fakebidiprefix;
// The fake bidi unicode gets popped at every newline so pushing it back at every newline.
for (int i = 0; i < p_message.size(); i++) {
for (int i = 0; i < p_message.length(); i++) {
if (p_message[i] == '\n') {
res += fakebidisuffix;
res += p_message[i];
@ -978,7 +978,7 @@ const char32_t *TranslationServer::get_accented_version(char32_t p_character) co
}
bool TranslationServer::is_placeholder(String &p_message, int p_index) const {
return p_index < p_message.size() - 1 && p_message[p_index] == '%' &&
return p_index < p_message.length() - 1 && p_message[p_index] == '%' &&
(p_message[p_index + 1] == 's' || p_message[p_index + 1] == 'c' || p_message[p_index + 1] == 'd' ||
p_message[p_index + 1] == 'o' || p_message[p_index + 1] == 'x' || p_message[p_index + 1] == 'X' || p_message[p_index + 1] == 'f');
}