Skip to content

String literals drop the backslash of unrecognized escape sequences #89

Description

@Nuhiat-Arefin

Escape sequences that the string-literal parser does not recognize lose their backslash. Python/Jinja2 keep the backslash of an unrecognized escape.

Reproduction

Template bytes: {{'\\\}'}}

Jinja2 renders \\} (two backslashes followed by a brace). ginger renders \}.

Inside a larger string, {{'\\\{N__xvada_ignored_ws_v1}'}} renders \\{N__xvada_ignored_ws_v1} in Jinja2 and \{N__xvada_ignored_ws_v1} in ginger.

Root cause

src/Text/Ginger/Parse.hs:1285-1304: after the named escapes (\n, \r, \b, \v, \0, \t), the catch-all at line 1303 returns the escaped character without the backslash.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions