diff options
| author | Rémi Verschelde | 2018-03-02 12:53:24 +0100 |
|---|---|---|
| committer | Hein-Pieter van Braam | 2018-03-02 14:54:45 +0100 |
| commit | 262c97098d6bca3067a396b666862db1a893a035 (patch) | |
| tree | 1de862c8ff4a0a5177b125f08a061c9448d0dab3 | |
| parent | cee20e24bda772ddf5daad1e42ba689f4eb94366 (diff) | |
| download | godot-262c97098d6bca3067a396b666862db1a893a035.tar.gz godot-262c97098d6bca3067a396b666862db1a893a035.tar.zst godot-262c97098d6bca3067a396b666862db1a893a035.zip | |
Fix serialization of identifiers with non printable ASCII characters
Fixes #6888.
(cherry picked from commit ab001d830b3822cbde4d987f7f49bb77e2edc2a0)
| -rw-r--r-- | scene/resources/scene_format_text.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index bb5295709..030b822f3 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; } |
