]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Don't skip an erroneous comma when parsing from
authorJack Wilsdon <jack.wilsdon@gmail.com>
Sun, 30 Oct 2016 21:57:12 +0000 (21:57 +0000)
committerDavid Lord <davidism@gmail.com>
Fri, 7 Jul 2017 16:42:16 +0000 (09:42 -0700)
Currently we skip an extra comma when "with context" is not provided to
the "from" statement. This allows invalid code such as this:

  {% from "functions.html" import my_function,, %}

The primary issue with this is that it is not consistent when providing
"with context". The following code throws an error, contrary to the
previous example:

  {% from "functions.html" import my_function,, with context %}

It seems that the comma skipping was originally found in 0611e49 and was
accidentally put inside the "with context" check in ea847c5. It was then
updated to use "skip_if" in fdf9530.

There doesn't seem to be any reason for this check existing, as
double commas should never be allowed and serve no purpose in the
statement.

jinja2/parser.py

index 08233642d0946696108c9a8aed990e74678ea746..f8d71bbe9e697acc9b2b86e1149961611759585d 100644 (file)
@@ -337,7 +337,6 @@ class Parser(object):
                 self.stream.expect('name')
         if not hasattr(node, 'with_context'):
             node.with_context = False
-            self.stream.skip_if('comma')
         return node
 
     def parse_signature(self, node):