You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-30 16:26:50 +00:00
String::format leave passed values untouched
If the passed value or key contains double quotation marks it will no
longer get removed.
(cherry picked from commit a403efb67c)
This commit is contained in:
committed by
Rémi Verschelde
parent
6179f76547
commit
3b5ee6a38a
@@ -2959,17 +2959,10 @@ String String::format(const Variant &values, String placeholder) const {
|
|||||||
if (value_arr.size() == 2) {
|
if (value_arr.size() == 2) {
|
||||||
Variant v_key = value_arr[0];
|
Variant v_key = value_arr[0];
|
||||||
String key = v_key;
|
String key = v_key;
|
||||||
if (key.left(1) == "\"" && key.right(key.length() - 1) == "\"") {
|
|
||||||
key = key.substr(1, key.length() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
Variant v_val = value_arr[1];
|
Variant v_val = value_arr[1];
|
||||||
String val = v_val;
|
String val = v_val;
|
||||||
|
|
||||||
if (val.left(1) == "\"" && val.right(val.length() - 1) == "\"") {
|
|
||||||
val = val.substr(1, val.length() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
new_string = new_string.replace(placeholder.replace("_", key), val);
|
new_string = new_string.replace(placeholder.replace("_", key), val);
|
||||||
} else {
|
} else {
|
||||||
ERR_PRINT(String("STRING.format Inner Array size != 2 ").ascii().get_data());
|
ERR_PRINT(String("STRING.format Inner Array size != 2 ").ascii().get_data());
|
||||||
@@ -2978,10 +2971,6 @@ String String::format(const Variant &values, String placeholder) const {
|
|||||||
Variant v_val = values_arr[i];
|
Variant v_val = values_arr[i];
|
||||||
String val = v_val;
|
String val = v_val;
|
||||||
|
|
||||||
if (val.left(1) == "\"" && val.right(val.length() - 1) == "\"") {
|
|
||||||
val = val.substr(1, val.length() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (placeholder.find("_") > -1) {
|
if (placeholder.find("_") > -1) {
|
||||||
new_string = new_string.replace(placeholder.replace("_", i_as_str), val);
|
new_string = new_string.replace(placeholder.replace("_", i_as_str), val);
|
||||||
} else {
|
} else {
|
||||||
@@ -2998,14 +2987,6 @@ String String::format(const Variant &values, String placeholder) const {
|
|||||||
String key = E->get();
|
String key = E->get();
|
||||||
String val = d[E->get()];
|
String val = d[E->get()];
|
||||||
|
|
||||||
if (key.left(1) == "\"" && key.right(key.length() - 1) == "\"") {
|
|
||||||
key = key.substr(1, key.length() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (val.left(1) == "\"" && val.right(val.length() - 1) == "\"") {
|
|
||||||
val = val.substr(1, val.length() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
new_string = new_string.replace(placeholder.replace("_", key), val);
|
new_string = new_string.replace(placeholder.replace("_", key), val);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user