diff --git a/pep2html.py b/pep2html.py
index cd020a3a0..791e60758 100755
--- a/pep2html.py
+++ b/pep2html.py
@@ -46,6 +46,10 @@ import errno
import random
import time
from io import open
+try:
+ from html import escape
+except ImportError:
+ from cgi import escape
REQUIRES = {'python': '2.6',
'docutils': '0.2.7'}
@@ -117,8 +121,8 @@ def fixanchor(current, match):
rfcnum = int(match.group('rfcnum'))
link = RFCURL % rfcnum
if link:
- return '%s' % (cgi.escape(link), cgi.escape(text))
- return cgi.escape(match.group(0)) # really slow, but it works...
+ return '%s' % (escape(link), escape(text))
+ return escape(match.group(0)) # really slow, but it works...
@@ -182,7 +186,7 @@ def fixfile(inpath, input_lines, outfile):
if pep:
title = "PEP " + pep + " -- " + title
if title:
- print('
%s' % cgi.escape(title), file=outfile)
+ print(' %s' % escape(title), file=outfile)
r = random.choice(list(range(64)))
print((
' \n'
@@ -241,20 +245,20 @@ def fixfile(inpath, input_lines, outfile):
else:
try:
url = PEPCVSURL % int(pep)
- v = '%s ' % (url, cgi.escape(date))
+ v = '%s ' % (url, escape(date))
except ValueError as error:
v = date
elif k.lower() in ('content-type',):
url = PEPURL % 9
pep_type = v or 'text/plain'
- v = '%s ' % (url, cgi.escape(pep_type))
+ v = '%s ' % (url, escape(pep_type))
elif k.lower() == 'version':
if v.startswith('$' 'Revision: ') and v.endswith(' $'):
- v = cgi.escape(v[11:-2])
+ v = escape(v[11:-2])
else:
- v = cgi.escape(v)
+ v = escape(v)
print(' %s: | %s |
' \
- % (cgi.escape(k), v), file=outfile)
+ % (escape(k), v), file=outfile)
print('', file=outfile)
print('', file=outfile)
print('
', file=outfile)