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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mitsuhiko
Copy link
Contributor

Basically needs tests.

@ThiefMaster
Copy link
Member

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

jackwilsdon and others added 2 commits July 7, 2017 08:42
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
@jackwilsdon jackwilsdon deleted the stricter-from-parsing branch September 17, 2018 00:25
@jackwilsdon jackwilsdon restored the stricter-from-parsing branch September 17, 2018 00:25
@jackwilsdon jackwilsdon deleted the stricter-from-parsing 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.

4 participants