Skip to content

Commit

Permalink
Fixed WML parser not properly handling unquoted keys with variables (f…
Browse files Browse the repository at this point in the history
…ixes #1236)

In cases such as `name=turn $var`, the key value would get parsed and serialized as
`turn$var`. The reason for this was that that string was broken down into 3 tokens:
"turn", "$", and "var". parser::parse_variable() handled these tokens, and the issue
was that "$" was considered a "misc" token instead of a string one. In cases where
two string tokens were added consecutively, a space would be added between them
(manually added spacing was not preserved). Since "$" did not count as a string, the
space was not added, which resulted in "turn$var". To fix that, I made the tokenizer
consider "$" a string token, so the spacing is correctly preserved.

For the record, despite what the bug report above says, wrapping the value in quotes
did work in lieu of this fix.
  • Loading branch information
Vultraz committed Feb 8, 2018
1 parent a09e2bb commit 13a4822
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/serialization/tokenizer.cpp
Expand Up @@ -137,7 +137,7 @@ const token &tokenizer::next_token()
FALLTHROUGH;

default:
if (is_alnum(current_)) {
if (is_alnum(current_) || current_ == '$') {
token_.type = token::STRING;
do {
token_.value += current_;
Expand All @@ -146,7 +146,7 @@ const token &tokenizer::next_token()
skip_comment();
next_char_fast();
}
} while (is_alnum(current_));
} while (is_alnum(current_) || current_ == '$');
} else {
token_.type = token::MISC;
token_.value += current_;
Expand Down

0 comments on commit 13a4822

Please sign in to comment.