Encodes property names properly in project.godot
This commit is contained in:
parent
2a4c528d06
commit
e7e095da3f
@ -769,10 +769,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
|
|||||||
|
|
||||||
String vstr;
|
String vstr;
|
||||||
VariantWriter::write_to_string(value, vstr);
|
VariantWriter::write_to_string(value, vstr);
|
||||||
if (F->get().find(" ") != -1)
|
file->store_string(F->get().property_name_encode() + "=" + vstr + "\n");
|
||||||
file->store_string(F->get().quote() + "=" + vstr + "\n");
|
|
||||||
else
|
|
||||||
file->store_string(F->get() + "=" + vstr + "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4059,6 +4059,19 @@ String String::percent_decode() const {
|
|||||||
return String::utf8(pe.ptr());
|
return String::utf8(pe.ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String String::property_name_encode() const {
|
||||||
|
// Escape and quote strings with extended ASCII or further Unicode characters
|
||||||
|
// as well as '"', '=' or ' ' (32)
|
||||||
|
const CharType *cstr = c_str();
|
||||||
|
for (int i = 0; cstr[i]; i++) {
|
||||||
|
if (cstr[i] == '=' || cstr[i] == '"' || cstr[i] < 33 || cstr[i] > 126) {
|
||||||
|
return "\"" + c_escape_multiline() + "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Keep as is
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
String String::get_basename() const {
|
String String::get_basename() const {
|
||||||
|
|
||||||
int pos = find_last(".");
|
int pos = find_last(".");
|
||||||
|
@ -338,6 +338,8 @@ public:
|
|||||||
String percent_encode() const;
|
String percent_encode() const;
|
||||||
String percent_decode() const;
|
String percent_decode() const;
|
||||||
|
|
||||||
|
String property_name_encode() const;
|
||||||
|
|
||||||
bool is_valid_identifier() const;
|
bool is_valid_identifier() const;
|
||||||
bool is_valid_integer() const;
|
bool is_valid_integer() const;
|
||||||
bool is_valid_float() const;
|
bool is_valid_float() const;
|
||||||
|
@ -1530,9 +1530,6 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
|
|||||||
} else if (c != '=') {
|
} else if (c != '=') {
|
||||||
what += String::chr(c);
|
what += String::chr(c);
|
||||||
} else {
|
} else {
|
||||||
if (p_stream->is_utf8()) {
|
|
||||||
what.parse_utf8(what.ascii(true).get_data());
|
|
||||||
}
|
|
||||||
r_assign = what;
|
r_assign = what;
|
||||||
Token token;
|
Token token;
|
||||||
get_token(p_stream, token, line, r_err_str);
|
get_token(p_stream, token, line, r_err_str);
|
||||||
|
@ -1459,20 +1459,6 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String _valprop(const String &p_name) {
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
|
Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
|
||||||
|
|
||||||
if (p_path.ends_with(".tscn")) {
|
if (p_path.ends_with(".tscn")) {
|
||||||
@ -1675,7 +1661,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
|
|||||||
|
|
||||||
String vars;
|
String vars;
|
||||||
VariantWriter::write_to_string(value, vars, _write_resources, this);
|
VariantWriter::write_to_string(value, vars, _write_resources, this);
|
||||||
f->store_string(_valprop(name) + " = " + vars + "\n");
|
f->store_string(name.property_name_encode() + " = " + vars + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1747,7 +1733,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
|
|||||||
String vars;
|
String vars;
|
||||||
VariantWriter::write_to_string(state->get_node_property_value(i, j), vars, _write_resources, this);
|
VariantWriter::write_to_string(state->get_node_property_value(i, j), vars, _write_resources, this);
|
||||||
|
|
||||||
f->store_string(_valprop(String(state->get_node_property_name(i, j))) + " = " + vars + "\n");
|
f->store_string(String(state->get_node_property_name(i, j)).property_name_encode() + " = " + vars + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < state->get_node_count() - 1)
|
if (i < state->get_node_count() - 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user