summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorsblondon <sblondon@users.noreply.github.com>2018-04-29 17:48:33 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-04-29 17:48:33 (GMT)
commit7d68bfa82654ba01d860b8a772ff63bf0bd183ee (patch)
treee4a03a4c0cfc7be75b1cdea0aba531b930a18461 /Lib
parent70af06cdc4e8fbee0b9d7d46bdc193097d4bc71f (diff)
downloadcpython-7d68bfa82654ba01d860b8a772ff63bf0bd183ee.zip
cpython-7d68bfa82654ba01d860b8a772ff63bf0bd183ee.tar.gz
cpython-7d68bfa82654ba01d860b8a772ff63bf0bd183ee.tar.bz2
bpo-33256: Replace angle brackets around python object repr to display it in html (GH-6442)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/cgitb.py4
-rw-r--r--Lib/test/test_cgitb.py1
2 files changed, 3 insertions, 2 deletions
diff --git a/Lib/cgitb.py b/Lib/cgitb.py
index b291100..0f5f32c 100644
--- a/Lib/cgitb.py
+++ b/Lib/cgitb.py
@@ -124,7 +124,7 @@ function calls leading up to the error, in the order they occurred.</p>'''
args, varargs, varkw, locals = inspect.getargvalues(frame)
call = ''
if func != '?':
- call = 'in ' + strong(func) + \
+ call = 'in ' + strong(pydoc.html.escape(func)) + \
inspect.formatargvalues(args, varargs, varkw, locals,
formatvalue=lambda value: '=' + pydoc.html.repr(value))
@@ -282,7 +282,7 @@ class Hook:
if self.display:
if plain:
- doc = doc.replace('&', '&amp;').replace('<', '&lt;')
+ doc = pydoc.html.escape(doc)
self.file.write('<pre>' + doc + '</pre>\n')
else:
self.file.write(doc + '\n')
diff --git a/Lib/test/test_cgitb.py b/Lib/test/test_cgitb.py
index a87a422..e299ec3 100644
--- a/Lib/test/test_cgitb.py
+++ b/Lib/test/test_cgitb.py
@@ -45,6 +45,7 @@ class TestCgitb(unittest.TestCase):
out = out.decode(sys.getfilesystemencoding())
self.assertIn("ValueError", out)
self.assertIn("Hello World", out)
+ self.assertIn("<strong>&lt;module&gt;</strong>", out)
# By default we emit HTML markup.
self.assertIn('<p>', out)
self.assertIn('</p>', out)