From f9728949cd1477868b656c2583f2568c6c28dce7 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sun, 23 Oct 2022 17:29:23 +0200 Subject: [PATCH] Switch to escape() from html The function was removed from the cgi module in Python 3.8. --- online_check/stdnum.wsgi | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/online_check/stdnum.wsgi b/online_check/stdnum.wsgi index 62e2d58b..74da5b44 100755 --- a/online_check/stdnum.wsgi +++ b/online_check/stdnum.wsgi @@ -19,6 +19,7 @@ """Simple WSGI application to check numbers.""" +import html import inspect import json import os @@ -69,7 +70,7 @@ def info(module, number): def format(data): """Return an HTML snippet describing the number.""" - description = cgi.escape(data['description']).replace('\n\n', '
\n') + description = html.escape(data['description']).replace('\n\n', '
\n') description = re.sub( r'^[*] (.*)$', r'', description, flags=re.MULTILINE) @@ -79,10 +80,10 @@ def format(data): description, flags=re.IGNORECASE + re.UNICODE) for name, conversion in data.get('conversions', {}).items(): description += '\n
%s: %s' % ( - cgi.escape(name), cgi.escape(conversion)) + html.escape(name), html.escape(conversion)) return '
  • %s: %s

    %s

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