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

Add stricter checking to "from ... import ..." #618

Merged
merged 2 commits into from Jul 7, 2017

Conversation

4 participants
@jackwilsdon
Contributor

jackwilsdon commented Oct 30, 2016

Currently token parsing on "from ... import ..." is rather loose — it sees the following invalid code as perfectly valid:

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

This is caused by the parser ignoring non-name values where there should be names, either as the first value or after commas.

This PR ensures only name values are allowed as the first value and any values after commas in the import section.

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

@davidism

Needs test. Otherwise, seems fine to me. Waiting for feedback from another maintainer.

@mitsuhiko

This comment has been minimized.

Show comment
Hide comment
@mitsuhiko

mitsuhiko Jan 6, 2017

Member

Basically needs tests.

Member

mitsuhiko commented Jan 6, 2017

Basically needs tests.

@ThiefMaster

This comment has been minimized.

Show comment
Hide comment
@ThiefMaster

ThiefMaster Mar 9, 2017

Member

@jackwilsdon are you still interested in your PR and willing to provide tests?

Member

ThiefMaster commented Mar 9, 2017

@jackwilsdon are you still interested in your PR and willing to provide tests?

jackwilsdon and others added some commits Oct 30, 2016

Add stricter checking to "from ... import ..."
Currently token parsing on "from ... import ..." is rather "loose" — it
sees the following "invalid" code as perfectly valid:

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

This is caused by the parser ignoring non-name values where there should
be names, either as the first value or after commas.

This commit ensures only name values are allowed as the first value and
any values after commas in the import section.

@davidism davidism merged commit a361b74 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