Skip to content

Don't skip an erroneous comma when parsing "from"#617

Merged
davidism merged 2 commits intopallets:masterfrom
jackwilsdon:dont-skip-comma
Jul 7, 2017
Merged

Don't skip an erroneous comma when parsing "from"#617
davidism merged 2 commits intopallets:masterfrom
jackwilsdon:dont-skip-comma

Conversation

@jackwilsdon
Copy link
Copy Markdown
Contributor

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 commas should never be allowed and serve no purpose in the statement.

Sadly this may be a "semi-breaking" change, as it removes some functionality that should have never existed and hopefully nobody relies on.

This PR ensures that both examples throw an error as expected.

Copy link
Copy Markdown
Member

@davidism davidism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs test.

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.
@davidism
Copy link
Copy Markdown
Member

davidism commented Jul 7, 2017

After #618, the example already fails, removing this doesn't change anything. However, since it seems redundant, I'll still remove it and add a test.

@davidism davidism merged commit 6f4d03c into pallets:master Jul 7, 2017
@jackwilsdon jackwilsdon deleted the dont-skip-comma branch September 17, 2018 00:25
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants