summaryrefslogtreecommitdiff
path: root/scene/resources/scene_format_text.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-03-02 14:44:12 +0100
committerGitHub <noreply@github.com>2018-03-02 14:44:12 +0100
commit79a07527ab87de385bf8fd8f7f9d7f09e55a77dc (patch)
tree6ce02a64a0b8c7f2dd5ebe363cf14e556b870a36 /scene/resources/scene_format_text.cpp
parent3bab5477ff44673e4e62b6a00804d0434d394fa7 (diff)
parentab001d830b3822cbde4d987f7f49bb77e2edc2a0 (diff)
Merge pull request #17178 from akien-mga/prop-serialization
Fix serialization of identifiers with non printable ASCII characters
Diffstat (limited to 'scene/resources/scene_format_text.cpp')
-rw-r--r--scene/resources/scene_format_text.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index bb5295709a..030b822f3b 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -1445,8 +1445,15 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
static String _valprop(const String &p_name) {
- if (p_name.find("\"") != -1 || p_name.find("=") != -1 || p_name.find(" ") != -1)
- return "\"" + p_name.c_escape_multiline() + "\"";
+ // Escape and quote strings with extended ASCII or further Unicode characters
+ // 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;
}