summaryrefslogtreecommitdiff
path: root/core/variant/variant_parser.cpp
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2021-07-05 15:46:10 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2021-07-05 15:46:41 +0300
commiteca4d2fcccddd31ef4183d4236d2f6fa002dfb07 (patch)
tree59294b1258478789ee8cdae95c7d5b4730d26531 /core/variant/variant_parser.cpp
parent3fbfb24773eda3a2ec12f70182fbf46ec925f05f (diff)
Fix Variant tags parsing.
Diffstat (limited to 'core/variant/variant_parser.cpp')
-rw-r--r--core/variant/variant_parser.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp
index e61ce1eeaa..86d5ae7f38 100644
--- a/core/variant/variant_parser.cpp
+++ b/core/variant/variant_parser.cpp
@@ -1204,16 +1204,32 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin
r_tag.name = "";
r_tag.fields.clear();
- while (true) {
- char32_t c = p_stream->get_char();
- if (p_stream->is_eof()) {
- r_err_str = "Unexpected EOF while parsing simple tag";
- return ERR_PARSE_ERROR;
+ if (p_stream->is_utf8()) {
+ CharString cs;
+ while (true) {
+ char c = p_stream->get_char();
+ if (p_stream->is_eof()) {
+ r_err_str = "Unexpected EOF while parsing simple tag";
+ return ERR_PARSE_ERROR;
+ }
+ if (c == ']') {
+ break;
+ }
+ cs += c;
}
- if (c == ']') {
- break;
+ r_tag.name.parse_utf8(cs.get_data(), cs.length());
+ } else {
+ while (true) {
+ char32_t c = p_stream->get_char();
+ if (p_stream->is_eof()) {
+ r_err_str = "Unexpected EOF while parsing simple tag";
+ return ERR_PARSE_ERROR;
+ }
+ if (c == ']') {
+ break;
+ }
+ r_tag.name += String::chr(c);
}
- r_tag.name += String::chr(c);
}
r_tag.name = r_tag.name.strip_edges();