[2.7] bpo-33256: Replace angle brackets around python object repr to display it in html (GH-6442). (GH-6650)
(cherry picked from commit 7d68bfa82654ba01d860b8a772ff63bf0bd183ee)
Co-authored-by: sblondon <sblondon@users.noreply.github.com>
diff --git a/Lib/cgitb.py b/Lib/cgitb.py
index 8acc4b7..3689f8a 100644
--- a/Lib/cgitb.py
+++ b/Lib/cgitb.py
@@ -125,7 +125,7 @@
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))
@@ -285,7 +285,7 @@
if self.display:
if plain:
- doc = doc.replace('&', '&').replace('<', '<')
+ doc = pydoc.html.escape(doc)
self.file.write('<pre>' + doc + '</pre>\n')
else:
self.file.write(doc + '\n')