Skip to content

Commit fc2ea87

Browse files
committed
issue2551136 - timezone extention crash on Python 3.8.
cgi.escape is used in some template to provide a select box of timezones. It uses cgi.escape that is depricated and removed from 3.8 and newer. Use html.escape with fallback to cgi.escape.
1 parent f0e4e6c commit fc2ea87

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ Fixed:
106106
- issue2550648 - keyword boolean search. Issue has multiple problems.
107107
Fix issue where saving the keyword boolean search would remove the
108108
link to open the editor.
109+
- issue2551136 - timezone extention crash on Python 3.8. cgi.escape
110+
is used in some template to provide a select box of timezones. It
111+
uses cgi.escape that is depricated and removed from 3.8 and newer.
112+
Use html.escape with fallback to cgi.escape. (Cedric Krier)
109113

110114
Features:
111115
- issue2550522 - Add 'filter' command to command-line

doc/upgrading.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,33 @@ property error. Now it stops after reporting the incorrect property.
7373
If run non-interactively, it exits with status 1. It can now be
7474
used in a startup script to detect permission errors.
7575

76+
Futureproof devel and responsive timezone selection extension
77+
-------------------------------------------------------------
78+
79+
The devel and responsive (derived from devel) templates use a select
80+
control to list all available timezones when pytz is used. It
81+
sanitizes the data using cgi.escape. Cgi.escape is deprecated and
82+
removed in newer pythons. Change your ``extensions/timezone.py``
83+
file by applying the following patch manually::
84+
85+
86+
-import cgi
87+
+try:
88+
+ from html import escape
89+
+except ImportError:
90+
+ from cgi import escape
91+
92+
try:
93+
import pytz
94+
@@ -25,7 +28,7 @@
95+
s = ' '
96+
if zone == value:
97+
s = 'selected=selected '
98+
- z = cgi.escape(zone)
99+
+ z = escape(zone)
100+
101+
See https://issues.roundup-tracker.org/issue2551136 for more details.
102+
76103
.. index:: Upgrading; 1.6.x to 2.0.0
77104

78105
Migrating from 1.6.X to 2.0.0

share/roundup/templates/devel/extensions/timezone.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Utility for replacing the simple input field for the timezone with
22
# a select-field that lists the available values.
33

4-
import cgi
4+
try:
5+
from html import escape
6+
except ImportError:
7+
from cgi import escape
58

69
try:
710
import pytz
@@ -25,7 +28,7 @@ def tzfield(prop, name, default):
2528
s = ' '
2629
if zone == value:
2730
s = 'selected=selected '
28-
z = cgi.escape(zone)
31+
z = escape(zone)
2932
l.append('<option %svalue="%s">%s</option>' % (s, z, z))
3033
l.append('</select>')
3134
return '\n'.join(l)

share/roundup/templates/responsive/extensions/timezone.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Utility for replacing the simple input field for the timezone with
22
# a select-field that lists the available values.
33

4-
import cgi
4+
try:
5+
from html import escape
6+
except ImportError:
7+
from cgi import escape
58

69
try:
710
import pytz
@@ -25,7 +28,7 @@ def tzfield(prop, name, default):
2528
s = ' '
2629
if zone == value:
2730
s = 'selected=selected '
28-
z = cgi.escape(zone)
31+
z = escape(zone)
2932
l.append('<option %svalue="%s">%s</option>' % (s, z, z))
3033
l.append('</select>')
3134
return '\n'.join(l)

0 commit comments

Comments
 (0)