Skip to content

Fix issues with escaping on double quote context

Michael Aaron Murphy requested to merge gnieto:fix/unescapedStrings into master

Created by: gnieto

Problem: There was an issue escaping strings on double quotes when a string was being extended. The issue is described here: https://github.com/redox-os/ion/issues/640

Solution: Escaping symbols on double-quote environment was not working as intended. The previous code, when it found a backslash on a quote, it generated a Word which finished with an escape backslash as text.

With the new code, when a backslash is found a word is emitted up to the backslash. After this, it checks if the following character should be escaped: If it shouldn't, we don't advance the cursor and we parse that backslash as text, on a following word. If it should be escaped, we advance the buffer, to avoid that the backslash is added to the following word.

Changes introduced by this pull request:

  • Changed how words are tokenized when extending a string

Drawbacks:

  • The new code, when finds a backslash needs to look ahead the following character to know if needs escaping or not.
  • A list of escaped characters is need

Fixes: https://github.com/redox-os/ion/issues/640

Merge request reports