Skip to content

Commit f972894

Browse files
committed
Switch to escape() from html
The function was removed from the cgi module in Python 3.8.
1 parent c5d3bf4 commit f972894

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

online_check/stdnum.wsgi

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
"""Simple WSGI application to check numbers."""
2121

22+
import html
2223
import inspect
2324
import json
2425
import os
@@ -69,7 +70,7 @@ def info(module, number):
6970

7071
def format(data):
7172
"""Return an HTML snippet describing the number."""
72-
description = cgi.escape(data['description']).replace('\n\n', '<br/>\n')
73+
description = html.escape(data['description']).replace('\n\n', '<br/>\n')
7374
description = re.sub(
7475
r'^[*] (.*)$', r'<ul><li>\1</li></ul>',
7576
description, flags=re.MULTILINE)
@@ -79,10 +80,10 @@ def format(data):
7980
description, flags=re.IGNORECASE + re.UNICODE)
8081
for name, conversion in data.get('conversions', {}).items():
8182
description += '\n<br/><b><i>%s</i></b>: %s' % (
82-
cgi.escape(name), cgi.escape(conversion))
83+
html.escape(name), html.escape(conversion))
8384
return '<li>%s: <b>%s</b><p>%s</p></li>' % (
84-
cgi.escape(data['number']),
85-
cgi.escape(data['name']),
85+
html.escape(data['number']),
86+
html.escape(data['name']),
8687
description)
8788

8889

@@ -115,5 +116,5 @@ def application(environ, start_response):
115116
('Content-Type', 'text/html; charset=utf-8'),
116117
('Vary', 'X-Requested-With')])
117118
return [(_template % dict(
118-
value=cgi.escape(number, True),
119+
value=html.escape(number, True),
119120
results=u'\n'.join(format(data) for data in results))).encode('utf-8')]

0 commit comments

Comments
 (0)