diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2023-01-12 21:53:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-12 21:53:15 +0100 |
commit | c2790ec2b9ef737e7bcc203d7f7e6faf31e95862 (patch) | |
tree | 115d0378371de8c02451561d86e8a335665577c8 /core/variant | |
parent | 886f7f8290738775db3a64f59d0a613465af64db (diff) | |
parent | 0d122ce45998b33e923ac406129f64b5e9f3affb (diff) |
Merge pull request #68450 from KoBeWi/bracket_escapist
Allow to escape closing brackets in CFG tags
Diffstat (limited to 'core/variant')
-rw-r--r-- | core/variant/variant_parser.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index 39a039ffe8..87874deb8d 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -1358,6 +1358,7 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin if (p_simple_tag) { r_tag.name = ""; r_tag.fields.clear(); + bool escaping = false; if (p_stream->is_utf8()) { CharString cs; @@ -1368,7 +1369,15 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin return ERR_PARSE_ERROR; } if (c == ']') { - break; + if (escaping) { + escaping = false; + } else { + break; + } + } else if (c == '\\') { + escaping = true; + } else { + escaping = false; } cs += c; } @@ -1381,7 +1390,15 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin return ERR_PARSE_ERROR; } if (c == ']') { - break; + if (escaping) { + escaping = false; + } else { + break; + } + } else if (c == '\\') { + escaping = true; + } else { + escaping = false; } r_tag.name += String::chr(c); } |