Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Jul 7, 2017
Merged

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

merged 2 commits into from Jul 7, 2017

Conversation

jackwilsdon
Copy link
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
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
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.

None yet

2 participants