Fix serialization of identifiers with non printable ASCII characters
Fixes #6888.
(cherry picked from commit ab001d830b
)
This commit is contained in:
parent
cee20e24bd
commit
262c97098d
|
@ -1445,8 +1445,15 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
|
||||||
|
|
||||||
static String _valprop(const String &p_name) {
|
static String _valprop(const String &p_name) {
|
||||||
|
|
||||||
if (p_name.find("\"") != -1 || p_name.find("=") != -1 || p_name.find(" ") != -1)
|
// Escape and quote strings with extended ASCII or further Unicode characters
|
||||||
return "\"" + p_name.c_escape_multiline() + "\"";
|
// as well as '"', '=' or ' ' (32)
|
||||||
|
const CharType *cstr = p_name.c_str();
|
||||||
|
for (int i = 0; cstr[i]; i++) {
|
||||||
|
if (cstr[i] == '=' || cstr[i] == '"' || cstr[i] < 33 || cstr[i] > 126) {
|
||||||
|
return "\"" + p_name.c_escape_multiline() + "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Keep as is
|
||||||
return p_name;
|
return p_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue