Skip to content

Commit 0f7ed35

Browse files
committed
address Unicode encoding issues in jinja2 template
issue2550811
1 parent aed20ab commit 0f7ed35

28 files changed

+274
-223
lines changed

CHANGES.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ Python v2.5 and v2.6. Starting with the v1.6 releases of Roundup
1111
v2.7.2 is required to run newer releases of Roundup.
1212

1313

14+
2018-??-?? ?.?.0
15+
16+
Fixed:
17+
18+
- issue2550811: work around Unicode encoding issues in jinja2 template
19+
by explicitly converting data to Unicode; also fixed pagination and
20+
selecting columns to display in the issues list (Christof Meerwald)
21+
22+
1423
2018-07-13 1.6.0
1524

1625
Features:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{% extends 'layout/page.html' %}
22

33
{% block head_title %}
4-
404 - {{ i18n.gettext('page not found') }}
4+
404 - {{ i18n.gettext('page not found')|u }}
55
{% endblock %}
66

77
{% block page_content %}
88
<div class='container-fluid'>
9-
<h1 class='text-error'>{{ i18n.gettext('404 - page not found') }}</h1>
10-
<p style='text-align: center'>{{ i18n.gettext('What were you looking for anyways?') }}</p>
9+
<h1 class='text-error'>{{ i18n.gettext('404 - page not found')|u }}</h1>
10+
<p style='text-align: center'>{{ i18n.gettext('What were you looking for anyways?')|u }}</p>
1111
</div>
1212
{% endblock %}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{% extends 'layout/page.html' %}
22

33
{% block head_title %}
4-
{{ i18n.gettext('Edit Collision') }} - {{ config.TRACKER_NAME }}
4+
{{ i18n.gettext('Edit Collision')|u }} - {{ config.TRACKER_NAME }}
55
{% endblock %}
66

77
{% block page_header %}
8-
{{ i18n.gettext('Edit Collision') }} - {{ config.TRACKER_NAME }}
8+
{{ i18n.gettext('Edit Collision')|u }} - {{ config.TRACKER_NAME }}
99
{% endblock %}
1010

1111
{% block content %}
1212
<p>
1313
{{ i18n.gettext('There has been a collision.
1414
Another user updated this node
1515
while you were editing. Please') }}
16-
<a href='{{ context }}'>{{ i18n.gettext('reload') }}</a>
17-
{{ i18n.gettext('the node and review your edits.') }}
16+
<a href='{{ context }}'>{{ i18n.gettext('reload')|u }}</a>
17+
{{ i18n.gettext('the node and review your edits.')|u }}
1818
</p>
19-
</tal:block>
19+
{% endblock %}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{% extends 'layout/page.html' %}
22

33
{% block head_title %}
4-
{{ i18n.gettext('Empty page') }}
4+
{{ i18n.gettext('Empty page')|u }}
55
{% endblock %}
66

77
{% block page_content %}
88
<p>
9-
{{ i18n.gettext('Please specify your search parameters!') }}
9+
{{ i18n.gettext('Please specify your search parameters!')|u }}
1010
</p>
1111
{% endblock %}

share/roundup/templates/jinja2/html/_generic.index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{% extends 'layout/page.html' %}
22

33
{% block head_title %}
4-
{{ context._classname.capitalize() }} {{ i18n.gettext('editing') }}
4+
{{ context._classname.capitalize() }} {{ i18n.gettext('editing')|u }}
55
{% endblock %}
66

77
{% block page_header %}
8-
{{ context._classname.capitalize() }} {{ i18n.gettext('editing') }}
8+
{{ context._classname.capitalize() }} {{ i18n.gettext('editing')|u }}
99
{% endblock %}
1010

1111
{% block content %}
@@ -32,11 +32,11 @@
3232
removed item and you know its id then just put that id in the id column.
3333
') }}</p>
3434
<form method="POST" action='{{ context.designator() }}'>
35-
<textarea rows="15" style="width:90%" name="rows">{{ context.csv }}</textarea>
35+
<textarea rows="15" style="width:90%" name="rows">{{ context.csv() }}</textarea>
3636
<br>
3737
<input name="@csrf" type="hidden" value="{{ utils.anti_csrf_nonce() }}">
38-
<input type="hidden" name="@action" value="{{ i18n.gettext('editCSV') }}">
39-
<input type="submit" value="{{ i18n.gettext('Edit Items') }}">
38+
<input type="hidden" name="@action" value="{{ i18n.gettext('editCSV')|u }}">
39+
<input type="submit" value="{{ i18n.gettext('Edit Items')|u }}">
4040
</form>
4141
{% endif %}
4242

share/roundup/templates/jinja2/html/file.index.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
<h4>{{ i18n.gettext('Files') }}</h4>
1+
<h4>{{ i18n.gettext('Files')|u }}</h4>
22
<table class='table'>
33
<tr>
4-
<th>{{ i18n.gettext('File name') }}</th>
5-
<th>{{ i18n.gettext('Uploaded') }}</th>
6-
<th>{{ i18n.gettext('Type') }}</th>
7-
<th>{{ i18n.gettext('Edit') }}</th>
8-
<th>{{ i18n.gettext('Remove') }}</th>
4+
<th>{{ i18n.gettext('File name')|u }}</th>
5+
<th>{{ i18n.gettext('Uploaded')|u }}</th>
6+
<th>{{ i18n.gettext('Type')|u }}</th>
7+
<th>{{ i18n.gettext('Edit')|u }}</th>
8+
<th>{{ i18n.gettext('Remove')|u }}</th>
99
</tr>
1010
{% for file in context.files %}
1111
<tr>
1212
<td>
13-
<a href='{{ file.download_url() }}'>{{ file.name }}</a>
13+
<a href='{{ file.download_url() }}'>{{ file.name|u|e }}</a>
1414
</td>
15-
<td>{{ file.creator }}, {{ file.creation }}</td>
16-
<td>{{ file.type }}</td>
15+
<td>{{ file.creator }}, {{ file.creation|u|e }}</td>
16+
<td>{{ file.type|u|e }}</td>
1717
{% if file.is_edit_ok %}
1818
<td>
19-
<a href='file{{ file.id }}'>{{ i18n.gettext('edit') }}</a>
19+
<a href='file{{ file.id }}'>{{ i18n.gettext('edit')|u }}</a>
2020
</td>
2121
{% endif %}
2222
{% if context.is_edit_ok %}
2323
<td>
2424
<form method="POST" action='issue{{ context.id }}'>
2525
<input type="hidden" name="@remove@files" value='{{ file.id }}'>
2626
<input name="@csrf" type="hidden" value="{{ utils.anti_csrf_nonce() }}">
27-
<input type="hidden" name="@action" value="{{ i18n.gettext('edit') }}">
28-
<input type="submit" value="{{ i18n.gettext('remove') }}">
27+
<input type="hidden" name="@action" value="{{ i18n.gettext('edit')|u }}">
28+
<input type="submit" value="{{ i18n.gettext('remove')|u }}">
2929
</form>
3030
</td>
3131
{% endif %}

share/roundup/templates/jinja2/html/file.item.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{% extends 'layout/page.html' %}
22

33
{% block head_title %}
4-
{{ i18n.gettext('File display') }}
4+
{{ i18n.gettext('File display')|u }}
55
{% endblock %}
66

77
{% block page_header %}
8-
{{ i18n.gettext('File display') }}
8+
{{ i18n.gettext('File display')|u }}
99
{% endblock %}
1010

1111
{% block content %}
@@ -17,10 +17,10 @@
1717
enctype="multipart/form-data" action='{{ context.designator() }}'>
1818

1919
<dl class='dl-horizontal'>
20-
<dt>{{ i18n.gettext('Name') }}</dt>
21-
<dd>{{ context.name.field() }}</dd>
22-
<dt>{{ i18n.gettext('Content Type') }}</dt>
23-
<dd>{{ context.type.field() }}</dd>
20+
<dt>{{ i18n.gettext('Name')|u }}</dt>
21+
<dd>{{ context.name.field()|u|e }}</dd>
22+
<dt>{{ i18n.gettext('Content Type')|u }}</dt>
23+
<dd>{{ context.type.field()|u|e }}</dd>
2424
</dl>
2525

2626
<input type="hidden" name="@template" value="item">
@@ -37,11 +37,11 @@
3737

3838
{% if context.id and context.is_view_ok() %}
3939
<div class='row-fluid'>
40-
<a href='file{{ context.id }}/{{ context.name }}'>{{ i18n.gettext('Download') }}</a>
40+
<a href='file{{ context.id }}/{{ context.name|u|e }}'>{{ i18n.gettext('Download')|u }}</a>
4141
</div>
4242
{% endif %}
4343

4444
<div class='vspace-five'></div>
45-
{{ context.history() }}
45+
{{ context.history()|u }}
4646

4747
{% endblock %}

share/roundup/templates/jinja2/html/home.classlist.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{% extends 'layout/page.html' %}
22

33
{% block head_title %}
4-
{{ i18n.gettext('List of classes') }}
4+
{{ i18n.gettext('List of classes')|u }}
55
{% endblock %}
66

77
{% block page_header %}
8-
{{ i18n.gettext('List of classes') }}
8+
{{ i18n.gettext('List of classes')|u }}
99
{% endblock %}
1010

1111
{% block content %}

share/roundup/templates/jinja2/html/home.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
filter=['status'],
55
columns=['id','activity','title','creator','assignedto', 'status'],
66
filterspec={'status':['-1','1','2','3','4','5','6','7']}
7-
)
7+
)|u
88
}}

share/roundup/templates/jinja2/html/issue.index.html

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{% extends 'layout/page.html' %}
22

33
{% block head_title %}
4-
{{ i18n.gettext('List of issues') }}
4+
{{ i18n.gettext('List of issues')|u }}
55
{% endblock %}
66

77
{% block page_header %}
8-
{{ i18n.gettext('List of issues') }}
8+
{{ i18n.gettext('List of issues')|u }}
99
{% endblock %}
1010

1111
{% block content %}
@@ -16,46 +16,82 @@
1616
{% if context.list() %}
1717
<table class='table'>
1818
<tr class='info'>
19-
<td>{{ i18n.gettext('Priority') }}</td>
20-
<td>{{ i18n.gettext('ID') }}</td>
21-
<td>{{ i18n.gettext('Activity') }}</td>
22-
<td>{{ i18n.gettext('Actor') }}</td>
23-
<td>{{ i18n.gettext('Keyword') }}</td>
24-
<td>{{ i18n.gettext('Title') }}</td>
25-
<td>{{ i18n.gettext('Status') }}</td>
26-
<td>{{ i18n.gettext('Creator') }}</td>
27-
<td>{{ i18n.gettext('Assigned To') }}</td>
19+
{% if request.show.priority %}
20+
<td>{{ i18n.gettext('Priority')|u }}</td>
21+
{% endif %}
22+
{% if request.show.id %}
23+
<td>{{ i18n.gettext('ID')|u }}</td>
24+
{% endif %}
25+
{% if request.show.activity %}
26+
<td>{{ i18n.gettext('Activity')|u }}</td>
27+
{% endif %}
28+
{% if request.show.actor %}
29+
<td>{{ i18n.gettext('Actor')|u }}</td>
30+
{% endif %}
31+
{% if request.show.keyword %}
32+
<td>{{ i18n.gettext('Keyword')|u }}</td>
33+
{% endif %}
34+
{% if request.show.title %}
35+
<td>{{ i18n.gettext('Title')|u }}</td>
36+
{% endif %}
37+
{% if request.show.status %}
38+
<td>{{ i18n.gettext('Status')|u }}</td>
39+
{% endif %}
40+
{% if request.show.creator %}
41+
<td>{{ i18n.gettext('Creator')|u }}</td>
42+
{% endif %}
43+
{% if request.show.assignedto %}
44+
<td>{{ i18n.gettext('Assigned To')|u }}</td>
45+
{% endif %}
2846
</tr>
2947
{% for issue in context.list() %}
3048
<tr>
31-
<td>{{ issue.priority.plain() }}</td>
49+
{% if request.show.priority %}
50+
<td>{{ issue.priority.plain()|u|e }}</td>
51+
{% endif %}
52+
{% if request.show.id %}
3253
<td>{{ issue.id }}</td>
54+
{% endif %}
55+
{% if request.show.activity %}
3356
<td>{{ issue.activity }}</td>
34-
<td>{{ issue.actor }}</td>
35-
<td>{{ issue.keyword.plain() }}</td>
57+
{% endif %}
58+
{% if request.show.actor %}
59+
<td>{{ issue.actor|u|e }}</td>
60+
{% endif %}
61+
{% if request.show.keyword %}
62+
<td>{{ issue.keyword.plain()|u|e }}</td>
63+
{% endif %}
64+
{% if request.show.title %}
3665
<td>
37-
<a href='issue{{ issue.id }}'>{{ issue.title.plain(hyperlink=0) }}</a>
66+
<a href='issue{{ issue.id }}'>{{ issue.title.plain(hyperlink=0)|u|e }}</a>
3867
</td>
39-
<td>{{ issue.status.plain() }}</td>
40-
<td>{{ issue.creator.plain() }}</td>
68+
{% endif %}
69+
{% if request.show.status %}
70+
<td>{{ issue.status.plain()|u|e }}</td>
71+
{% endif %}
72+
{% if request.show.creator %}
73+
<td>{{ issue.creator.plain()|u|e }}</td>
74+
{% endif %}
75+
{% if request.show.assignedto %}
4176
<td>{{ issue.assignedto.plain() }}</td>
77+
{% endif %}
4278
</tr>
4379
{% endfor %}
4480
</table>
4581
{% include 'layout/pagination.html' %}
46-
<div class='row-fluid'>
82+
<div class='row-fluid'>
4783
<div class='pull-right'>
4884
<a class='btn btn-success'
4985
href="{{ request.indexargs_url('issue', {'@action':'export_csv'}) }}">
50-
{{ i18n.gettext('Download as CSV') }}
86+
{{ i18n.gettext('Download as CSV')|u }}
5187
</a>
5288
</div>
5389
</div>
5490

5591
{% include 'layout/sort.html' %}
5692

5793
{% else %}
58-
<p class='text-error'>{{ i18n.gettext('There are no issues yet!') }}</p>
94+
<p class='text-error'>{{ i18n.gettext('There are no issues yet!')|u }}</p>
5995
{% endif %}
6096

6197
{% endif %}

0 commit comments

Comments
 (0)