Skip to content

Commit ab8e73a

Browse files
committed
Included django.utils.html.escape() in the linkify() code, and removed it from various templates, to make sure escape is consistently applied before linkify. Fixes issue ietf-tools#2492.
- Legacy-Id: 15035
1 parent b5d6297 commit ab8e73a

8 files changed

Lines changed: 11 additions & 10 deletions

ietf/templates/doc/document_ballot_content.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ <h4 class="anchor-target" id="{{ p.ad.plain_name|slugify }}">
9393
<div class="panel-heading">
9494
<h5 class="panel-title"><b>{{ p.pos.name }}</b> ({{ p.discuss_time|date:"Y-m-d" }}{% if not p.for_current_revision %} for -{{ p.get_dochistory.rev}}{% endif %})</h5>
9595
</div>
96-
<div class="panel-body"><pre class="ballot pasted">{{ p.discuss|escape|linkify }}</pre></div>
96+
<div class="panel-body"><pre class="ballot pasted">{{ p.discuss|linkify }}</pre></div>
9797
</div>
9898
{% endif %}
9999

@@ -102,7 +102,7 @@ <h5 class="panel-title"><b>{{ p.pos.name }}</b> ({{ p.discuss_time|date:"Y-m-d"
102102
<div class="panel-heading">
103103
<h5 class="panel-title"><b>Comment</b> ({{ p.comment_time|date:"Y-m-d" }}{% if not p.for_current_revision %} for -{{ p.get_dochistory.rev}}{% endif %})</h5>
104104
</div>
105-
<div class="panel-body"><pre class="ballot pasted">{{ p.comment|escape|linkify }}</pre></div>
105+
<div class="panel-body"><pre class="ballot pasted">{{ p.comment|linkify }}</pre></div>
106106
</div>
107107
{% endif %}
108108
{% endfor %}

ietf/templates/doc/document_review.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@
5555
<h2>{{ doc.type.name }}<br><small>{{ doc.name }}</small></h2>
5656

5757
{% if doc.rev and content != None %}
58-
<pre class="pasted">{{ content|linkify|safe|sanitize }}</pre>
58+
<pre class="pasted">{{ content|linkify }}</pre>
5959
{% endif %}
6060
{% endblock %}

ietf/templates/doc/drafts_in_iesg_process.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h1>{{ title }}</h1>
4747
<a href="{% url "ietf.doc.views_doc.document_main" doc.name %}">{{ doc.name }}</a>
4848
<br><b>{{ doc.title }}</b>
4949
{% if doc.note %}
50-
<br><i>Note: {{ doc.note|linebreaksbr|linkify }}</i>
50+
<br><i>Note: {{ doc.note|linkify|linebreaksbr }}</i>
5151
{% endif %}
5252
</td>
5353
<td>{{ doc.intended_std_level.name }}</td>

ietf/templates/doc/shepherd_writeup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{% origin %}
1313
<h1>Shepherd writeup<br><small>{{ doc.canonical_name }}-{{ doc.rev }}</small></h1>
1414

15-
<pre class="pasted">{{writeup|escape|linkify}}</pre>
15+
<pre class="pasted">{{writeup|linkify}}</pre>
1616

1717
{% if can_edit %}
1818
<a class="btn btn-primary" href="{% url 'ietf.doc.views_draft.edit_shepherd_writeup' name=doc.name %}">Edit</a>

ietf/templates/group/all_status.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h2> {{area_item.grouper.acronym|upper}}
2929
<span class="label label-success">{{ rpt.group.state.slug|upper }}</span>
3030
{% endif %}
3131
<br> {{rpt.time|date:"Y-m-d"}}</td>
32-
<td><pre class="pasted">{{ rpt.desc|default:"(none)"|escape|linkify }}</pre></td>
32+
<td><pre class="pasted">{{ rpt.desc|default:"(none)"|linkify }}</pre></td>
3333
</tr>
3434
{% endfor %}
3535
</table>
@@ -44,7 +44,7 @@ <h2> IRTF <small>Internet Research Task Force</small> </h2>
4444
<span class="label label-success">{{ rpt.group.state.slug|upper }}</span>
4545
{% endif %}
4646
<br> {{rpt.time|date:"Y-m-d"}}</td>
47-
<td><pre class="pasted">{{ rpt.desc|default:"(none)"|escape|linkify }}</pre></td>
47+
<td><pre class="pasted">{{ rpt.desc|default:"(none)"|linkify }}</pre></td>
4848
</tr>
4949
{% endfor %}
5050
</table>

ietf/templates/group/group_about_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h1>
1616
Status update for {{ group.type.name }} {{ group.acronym }}
1717
</h1>
1818

19-
<pre class="pasted">{{ status_update.desc|default:"(none)"|escape|linkify }}</pre>
19+
<pre class="pasted">{{ status_update.desc|default:"(none)"|linkify }}</pre>
2020

2121
{% if can_provide_status_update %}
2222
<a id="edit_button" class="btn btn-primary" href="{% url "ietf.group.views.group_about_status_edit" acronym=group.acronym %}">Edit</a>

ietf/templates/group/group_about_status_meeting.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h1>
1616
Status update for {{ group.type.name }} {{ group.acronym }} at {{meeting}}
1717
</h1>
1818

19-
<pre class="pasted">{{ status_update.desc|default:"(none)"|escape|linkify }}</pre>
19+
<pre class="pasted">{{ status_update.desc|default:"(none)"|linkify }}</pre>
2020

2121
<a class="btn btn-default pull-right" href="{% url "ietf.meeting.views.proceedings" num=meeting.number %}">Back</a>
2222

ietf/utils/templatetags/textfilters.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django import template
66
from django.template.defaultfilters import stringfilter
7+
from django.utils.html import escape
78
from django.utils.safestring import mark_safe
89

910
import debug # pyflakes:ignore
@@ -71,5 +72,5 @@ def texescape_filter(value):
7172
@register.filter
7273
@stringfilter
7374
def linkify(value):
74-
text = mark_safe(bleach.linkify(value))
75+
text = mark_safe(bleach.linkify(escape(value)))
7576
return text

0 commit comments

Comments
 (0)