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
Merged

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

merged 2 commits into from Jul 7, 2017

Conversation

jackwilsdon
Copy link
Contributor

@jackwilsdon 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 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 Jul 7, 2017
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
@jackwilsdon jackwilsdon deleted the stricter-from-parsing branch Sep 17, 2018
@jackwilsdon jackwilsdon restored the stricter-from-parsing branch Sep 17, 2018
@jackwilsdon jackwilsdon deleted the stricter-from-parsing branch Sep 17, 2018
@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

4 participants