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

jinja2 autoescape codemod should allow for setting autoescape to select_autoescape callable #285

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

clavedeluna
Copy link
Contributor

Description

  • setting autoescape=select_autoescape(...) is the encouraged way in the jinja2 docs:

Intelligently sets the initial value of autoescaping based on the filename of the template. This is the recommended way to configure autoescaping if you do not want to write a custom function yourself.

  • we had inadvertently flagged this as needing to change.
  • It would be nice to one day be able to also not flag any callable which may return True, but that is more difficult than it sounds due to branch analysis.
  • As a side thing, I noticed that we incorrectly interpreted the aiohttp_jinja2.setup default for autoescape as also being default of False, however, it's actually the secure value of True. I thought maybe that was a recent change but not so, it's been there for a while since v0.15
  • So I changed the pattern for aiohttp_jinja2.setup and also allowed it to accept jinja2.select_autoescape since the docs state this is passed directly to jinja's Environment class

Closes #284

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@clavedeluna clavedeluna added this pull request to the merge queue Feb 21, 2024
Merged via the queue into main with commit a054ed8 Feb 21, 2024
12 checks passed
@clavedeluna clavedeluna deleted the autoescape-fix branch February 21, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enable-jinja2-autoescape should not change if autoescape=select_autoescape()
2 participants