Skip to content

Commit f51a340

Browse files
committed
catching last couple of cgi.escape references.
1 parent 2d88b80 commit f51a340

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

roundup/cgi/client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
class SysCallError(Exception):
2424
pass
2525

26+
try:
27+
from html import escape as html_escape # python 3
28+
except ImportError:
29+
from cgi import escape as html_escape # python 2 fallback
30+
2631
from roundup import roundupdb, date, hyperdb, password
2732
from roundup.cgi import templating, cgitb, TranslationService
2833
from roundup.cgi import actions
@@ -68,7 +73,7 @@ def initialiseSecurity(security):
6873

6974
def add_message(msg_list, msg, escape=True):
7075
if escape:
71-
msg = cgi.escape(msg).replace('\n', '<br />\n')
76+
msg = html_escape(msg).replace('\n', '<br />\n')
7277
else:
7378
msg = msg.replace('\n', '<br />\n')
7479
msg_list.append (msg)
@@ -1767,9 +1772,9 @@ def renderContext(self):
17671772
result = result.replace('</body>', s)
17681773
return result
17691774
except templating.NoTemplate as message:
1770-
return '<strong>%s</strong>'%cgi.escape(str(message))
1775+
return '<strong>%s</strong>'%html_escape(str(message))
17711776
except templating.Unauthorised as message:
1772-
raise Unauthorised(cgi.escape(str(message)))
1777+
raise Unauthorised(html_escape(str(message)))
17731778
except:
17741779
# everything else
17751780
if self.instance.config.WEB_DEBUG:
@@ -1862,7 +1867,7 @@ def get_action_class(self, action_name):
18621867
if name == action_name:
18631868
break
18641869
else:
1865-
raise ValueError('No such action "%s"'%cgi.escape(action_name))
1870+
raise ValueError('No such action "%s"'%html_escape(action_name))
18661871
return action_klass
18671872

18681873
def _socket_op(self, call, *args, **kwargs):

0 commit comments

Comments
 (0)