Skip to content

Commit

Permalink
Merge pull request godotengine#17178 from akien-mga/prop-serialization
Browse files Browse the repository at this point in the history
Fix serialization of identifiers with non printable ASCII characters
  • Loading branch information
akien-mga authored Mar 2, 2018
2 parents 3bab547 + ab001d8 commit 79a0752
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scene/resources/scene_format_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 79a0752

Please sign in to comment.