Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
e7e095da
Commit
e7e095da
authored
Dec 20, 2019
by
Haoyu Qiu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Encodes property names properly in project.godot
parent
2a4c528d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
23 deletions
+18
-23
project_settings.cpp
core/project_settings.cpp
+1
-4
ustring.cpp
core/ustring.cpp
+13
-0
ustring.h
core/ustring.h
+2
-0
variant_parser.cpp
core/variant_parser.cpp
+0
-3
resource_format_text.cpp
scene/resources/resource_format_text.cpp
+2
-16
No files found.
core/project_settings.cpp
View file @
e7e095da
...
...
@@ -769,10 +769,7 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
String
vstr
;
VariantWriter
::
write_to_string
(
value
,
vstr
);
if
(
F
->
get
().
find
(
" "
)
!=
-
1
)
file
->
store_string
(
F
->
get
().
quote
()
+
"="
+
vstr
+
"
\n
"
);
else
file
->
store_string
(
F
->
get
()
+
"="
+
vstr
+
"
\n
"
);
file
->
store_string
(
F
->
get
().
property_name_encode
()
+
"="
+
vstr
+
"
\n
"
);
}
}
...
...
core/ustring.cpp
View file @
e7e095da
...
...
@@ -4059,6 +4059,19 @@ String String::percent_decode() const {
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
{
int
pos
=
find_last
(
"."
);
...
...
core/ustring.h
View file @
e7e095da
...
...
@@ -338,6 +338,8 @@ public:
String
percent_encode
()
const
;
String
percent_decode
()
const
;
String
property_name_encode
()
const
;
bool
is_valid_identifier
()
const
;
bool
is_valid_integer
()
const
;
bool
is_valid_float
()
const
;
...
...
core/variant_parser.cpp
View file @
e7e095da
...
...
@@ -1530,9 +1530,6 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
}
else
if
(
c
!=
'='
)
{
what
+=
String
::
chr
(
c
);
}
else
{
if
(
p_stream
->
is_utf8
())
{
what
.
parse_utf8
(
what
.
ascii
(
true
).
get_data
());
}
r_assign
=
what
;
Token
token
;
get_token
(
p_stream
,
token
,
line
,
r_err_str
);
...
...
scene/resources/resource_format_text.cpp
View file @
e7e095da
...
...
@@ -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
)
{
if
(
p_path
.
ends_with
(
".tscn"
))
{
...
...
@@ -1675,7 +1661,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
String
vars
;
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
;
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment