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

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

Merged
merged 2 commits into from Jul 7, 2017

Conversation

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

Copy link
Member

davidism left a comment

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

@mitsuhiko
Copy link
Member

mitsuhiko commented Jan 6, 2017

Basically needs tests.

@ThiefMaster
Copy link
Member

ThiefMaster commented Mar 9, 2017

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

jackwilsdon and others added 2 commits 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 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
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jackwilsdon jackwilsdon deleted the jackwilsdon:stricter-from-parsing branch Sep 17, 2018
@jackwilsdon jackwilsdon restored the jackwilsdon:stricter-from-parsing branch Sep 17, 2018
@jackwilsdon jackwilsdon deleted the jackwilsdon:stricter-from-parsing branch Sep 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.