Replace cgi.escape by html.escape.

cgi.escape is deprecated:
https://docs.python.org/3.4/library/cgi.html#cgi.escape
This commit is contained in:
Florian Bruhin 2014-08-05 23:20:26 +02:00
parent f1a8f91d51
commit 60d4dafbbb
3 changed files with 9 additions and 9 deletions

View File

@ -24,7 +24,7 @@ Module attributes:
pyeval_output: The output of the last :pyeval command. pyeval_output: The output of the last :pyeval command.
""" """
import cgi import html
from PyQt5.QtNetwork import QNetworkReply from PyQt5.QtNetwork import QNetworkReply
@ -112,13 +112,13 @@ class QuteHandlers:
@classmethod @classmethod
def pyeval(cls): def pyeval(cls):
"""Handler for qute:pyeval. Return HTML content as bytes.""" """Handler for qute:pyeval. Return HTML content as bytes."""
text = cgi.escape(pyeval_output) text = html.escape(pyeval_output)
return _get_html('pyeval', '<pre>{}</pre>'.format(text)) return _get_html('pyeval', '<pre>{}</pre>'.format(text))
@classmethod @classmethod
def version(cls): def version(cls):
"""Handler for qute:version. Return HTML content as bytes.""" """Handler for qute:version. Return HTML content as bytes."""
text = cgi.escape(version.version()) text = html.escape(version.version())
html = '<h1>Version info</h1>' html = '<h1>Version info</h1>'
html += '<p>{}</p>'.format(text.replace('\n', '<br/>')) html += '<p>{}</p>'.format(text.replace('\n', '<br/>'))
html += '<h1>Copyright info</h1>' html += '<h1>Copyright info</h1>'
@ -132,7 +132,7 @@ class QuteHandlers:
if logutils.ram_handler is None: if logutils.ram_handler is None:
text = "Log output was disabled." text = "Log output was disabled."
else: else:
text = cgi.escape(logutils.ram_handler.dump_log()) text = html.escape(logutils.ram_handler.dump_log())
return _get_html('log', '<pre>{}</pre>'.format(text)) return _get_html('log', '<pre>{}</pre>'.format(text))
@classmethod @classmethod

View File

@ -22,7 +22,7 @@
import re import re
import os import os
import sys import sys
import cgi import html
import logging import logging
from contextlib import contextmanager from contextlib import contextmanager
from logging import getLogger from logging import getLogger
@ -383,7 +383,7 @@ class HTMLFormatter(logging.Formatter):
for field in ['msg', 'filename', 'funcName', 'levelname', 'module', for field in ['msg', 'filename', 'funcName', 'levelname', 'module',
'name', 'pathname', 'processName', 'threadName']: 'name', 'pathname', 'processName', 'threadName']:
data = str(getattr(record, field)) data = str(getattr(record, field))
setattr(record, field, cgi.escape(data)) setattr(record, field, html.escape(data))
message = super().format(record) message = super().format(record)
if not message.endswith(self._colordict['reset']): if not message.endswith(self._colordict['reset']):
message += self._colordict['reset'] message += self._colordict['reset']
@ -391,4 +391,4 @@ class HTMLFormatter(logging.Formatter):
def formatTime(self, record, datefmt=None): def formatTime(self, record, datefmt=None):
out = super().formatTime(record, datefmt) out = super().formatTime(record, datefmt)
return cgi.escape(out) return html.escape(out)

View File

@ -22,7 +22,7 @@
import re import re
import os import os
import sys import sys
import cgi import html
import shutil import shutil
import inspect import inspect
import subprocess import subprocess
@ -375,7 +375,7 @@ def generate_settings(f):
f.write(" * +{}+".format(val) + "\n") f.write(" * +{}+".format(val) + "\n")
f.write("\n") f.write("\n")
if option.default: if option.default:
f.write("Default: +pass:[{}]+\n".format(cgi.escape( f.write("Default: +pass:[{}]+\n".format(html.escape(
option.default))) option.default)))
else: else:
f.write("Default: empty\n") f.write("Default: empty\n")