This commit is contained in:
Florian Bruhin 2014-08-05 23:23:15 +02:00
parent 60d4dafbbb
commit 7818366f0a
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 html import html as pyhtml
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 = html.escape(pyeval_output) text = pyhtml.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 = html.escape(version.version()) text = pyhtml.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 = html.escape(logutils.ram_handler.dump_log()) text = pyhtml.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

@ -1139,12 +1139,12 @@ class FontTests(unittest.TestCase):
def test_transform(self): def test_transform(self):
"""Test transform.""" """Test transform."""
for string, desc in self.TESTS.items(): for string, desc in self.TESTS.items():
with self.subTest(val=val): with self.subTest(string=string, desc=desc):
with self.subTest(t="t1"): with self.subTest(t="t1"):
self.assertEqual(self.t.transform(string), string, string) self.assertEqual(self.t.transform(string), string, string)
with self.subTest(t="t2"): with self.subTest(t="t2"):
self.assertEqual(Font(self.t2.transform(string)), self.assertEqual(Font(self.t2.transform(string)),
Font.fromdesc(desc), string) Font.fromdesc(desc), string)
def test_transform_empty(self): def test_transform_empty(self):
"""Test transform with an empty value.""" """Test transform with an empty value."""

View File

@ -22,7 +22,7 @@
import re import re
import os import os
import sys import sys
import html import html as pyhtml
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, html.escape(data)) setattr(record, field, pyhtml.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 html.escape(out) return pyhtml.escape(out)