From 0348fe32b2f5c7d80789143f3e69ccfc6e7dd319 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 20 Oct 2024 21:04:25 -0400 Subject: [PATCH] dont consume ampersands Fixed long standing bug where the sequence ``<&`` would be misinterpreted by the lexer. It's not clear why the ampersand character was part of the characters being consumed here and it may have been an inadvertent bit of code from one of Mako's predecessor languages. Fixes: #412 Change-Id: I41ba50da919a6c8b3557bdd2313aa545b51b2b9b --- doc/build/unreleased/412.rst | 8 ++++++++ mako/lexer.py | 2 +- test/test_lexer.py | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 doc/build/unreleased/412.rst diff --git a/doc/build/unreleased/412.rst b/doc/build/unreleased/412.rst new file mode 100644 index 00000000..3ee9bb62 --- /dev/null +++ b/doc/build/unreleased/412.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, lexer + :tickets: 412 + + Fixed long standing bug where the sequence ``<&`` would be misinterpreted + by the lexer. It's not clear why the ampersand character was part of the + characters being consumed here and it may have been an inadvertent bit of + code from one of Mako's predecessor languages. diff --git a/mako/lexer.py b/mako/lexer.py index 9d1f5f30..b4a76a45 100644 --- a/mako/lexer.py +++ b/mako/lexer.py @@ -375,7 +375,7 @@ def match_text(self): | (?=\${) # an expression | - (?=; + +""" + nodes = Lexer(template).parse() + self._compare( + nodes, + TemplateNode({}, [Text("\nproperty = <&node>;\n\n", (1, 1))]), + ) + def _dont_test_dict_expression_issue_400(self): """test for issue #400""" template = """