Skip to content

Commit

Permalink
Merge pull request #49291 from NoFr1ends/fix-49262
Browse files Browse the repository at this point in the history
String::format leave passed values untouched
  • Loading branch information
akien-mga authored Jul 13, 2021
2 parents 3adb129 + a403efb commit e2b79e9
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions core/string/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3397,17 +3397,10 @@ String String::format(const Variant &values, String placeholder) const {
if (value_arr.size() == 2) {
Variant v_key = value_arr[0];
String key = v_key;
if (key.left(1) == "\"" && key.right(1) == "\"") {
key = key.substr(1, key.length() - 2);
}

Variant v_val = value_arr[1];
String val = v_val;

if (val.left(1) == "\"" && val.right(1) == "\"") {
val = val.substr(1, val.length() - 2);
}

new_string = new_string.replace(placeholder.replace("_", key), val);
} else {
ERR_PRINT(String("STRING.format Inner Array size != 2 ").ascii().get_data());
Expand All @@ -3416,10 +3409,6 @@ String String::format(const Variant &values, String placeholder) const {
Variant v_val = values_arr[i];
String val = v_val;

if (val.left(1) == "\"" && val.right(1) == "\"") {
val = val.substr(1, val.length() - 2);
}

if (placeholder.find("_") > -1) {
new_string = new_string.replace(placeholder.replace("_", i_as_str), val);
} else {
Expand All @@ -3436,14 +3425,6 @@ String String::format(const Variant &values, String placeholder) const {
String key = E->get();
String val = d[E->get()];

if (key.left(1) == "\"" && key.right(1) == "\"") {
key = key.substr(1, key.length() - 2);
}

if (val.left(1) == "\"" && val.right(1) == "\"") {
val = val.substr(1, val.length() - 2);
}

new_string = new_string.replace(placeholder.replace("_", key), val);
}
} else {
Expand Down

0 comments on commit e2b79e9

Please sign in to comment.