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

should not escape block.Super #301

Merged
merged 2 commits into from
Jun 24, 2022

Conversation

kohkimakimoto
Copy link
Contributor

@kohkimakimoto kohkimakimoto commented Jun 24, 2022

This PR changes the block.Super output. Because the output content should not be escaped.

The block.Super in the current implementation returns an escaped content. Please see the following example.

layout.tpl

{% block content %}<h1>Title</h1>{% endblock %}

page.tpl

{% extends "layout.tpl" %}

{% block content %}
{{ block.Super }}
<p>page contents</p>
{% endblock %}

These templates output the following content.

&lt;h1&gt;Title&lt;/h1&gt;
<p>page contents</p>

But it is not the same behavior as Django template. The Django official document (https://django.readthedocs.io/en/1.7.x/topics/templates.html) says the following.

Data inserted using {{ block.super }} will not be automatically escaped (see the next section), since it was already escaped, if necessary, in the parent template.

Therefore, block.Super should output content that is not escaped from like the following.

<h1>Title</h1>
<p>page contents</p>

@sonarcloud
Copy link

sonarcloud bot commented Jun 24, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@flosch
Copy link
Owner

flosch commented Jun 24, 2022

Thanks for pointing this out and your fix.

@flosch flosch merged commit d76aea8 into flosch:master Jun 24, 2022
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.

2 participants