Skip to content

Commit

Permalink
Changed cgi.escape to html.escape (#106)
Browse files Browse the repository at this point in the history
* Changed cgi.escape to html.escape. Fixes #96

* Improved compatibility with old Python's versions and PyPy
  • Loading branch information
BraulioV authored Aug 4, 2021
1 parent 19abe52 commit 3252f9f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions libpip2pi/commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import re
import sys
import cgi
import shutil
import atexit
import tempfile
Expand All @@ -13,6 +12,11 @@
import glob
import optparse

try:
from html import escape
except ImportError:
from cgi import escape

try:
import wheel as _; _
has_wheel = True
Expand Down Expand Up @@ -374,15 +378,15 @@ def _dir2pi(option, argv):

if pkg_name not in processed_pkg:
pkg_index += "<a href='%s/'>%s</a><br />\n" %(
cgi.escape(pkg_dir_name),
cgi.escape(pkg_name),
escape(pkg_dir_name),
escape(pkg_name),
)
processed_pkg.add(pkg_name)

if option.build_html:
with open(os.path.join(pkg_dir, "index.html"), "a") as fp:
fp.write("<a href='%(name)s'>%(name)s</a><br />\n" %{
"name": cgi.escape(pkg_basename),
"name": escape(pkg_basename),
})
pkg_index += "</body></html>\n"

Expand Down

0 comments on commit 3252f9f

Please sign in to comment.