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

Conversation

2 participants
@jackwilsdon
Contributor

jackwilsdon commented Oct 30, 2016

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.

@davidism

Needs test.

Don't skip an erroneous comma when parsing from
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

This comment has been minimized.

Show comment
Hide comment
@davidism

davidism Jul 7, 2017

Member

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.

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

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment