]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Dot accessors can only be identifiers
authorKevin <kevin@kevin-brown.com>
Sun, 10 May 2020 14:48:16 +0000 (10:48 -0400)
committerKevin <kevin@kevin-brown.com>
Sun, 10 May 2020 14:48:16 +0000 (10:48 -0400)
This fixes a bug where the grammar allowed dot accessors to be any
variable type. This results in the filters that were meant for the
variable that was being accessed to be captured by the accessor
itself, which generated an unexpected and invalid AST.

grammar.ebnf
new_parser.py

index 314e9341c813680a667d543f0c4ca9ab47ba8549..0738c4e8fa9f526ef0567ba76bc000f077ca4934 100644 (file)
@@ -166,7 +166,7 @@ variable_accessor_call
 variable_accessor_dot\r
     =\r
     accessor_type:`dot`\r
-    "." parameter:variable_identifier\r
+    "." parameter:IDENTIFIER\r
     ;\r
 \r
 variable_accessor_call_parameters\r
index 40324c701893408b1d5792b910e2d1cacbd91b7c..e041e6d6426111d2f628963fb8a8a1288d259a29 100644 (file)
@@ -119,7 +119,7 @@ def parse_variable_accessor(node, ast):
         accessor_node.arg = parse_variable(ast['parameter'])\r
     elif accessor_type == 'dot':\r
         accessor_node = nodes.Getattr()\r
-        accessor_node.attr = ast['parameter']['variable']\r
+        accessor_node.attr = ast['parameter']\r
 \r
     accessor_node.node = node\r
     accessor_node.ctx = "load"\r