Skip to content

Commit

Permalink
Merge pull request #50177 from bruvzg/fix_variant_tags
Browse files Browse the repository at this point in the history
Fix Variant tags parsing.
  • Loading branch information
akien-mga authored Jul 5, 2021
2 parents 67ed879 + eca4d2f commit 26b86c1
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions core/variant/variant_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 26b86c1

Please sign in to comment.