Catch KeyError when quoting URLs of index.html.

This commit is contained in:
Bastian Kleineidam 2010-07-30 20:12:52 +02:00
parent 4678802a81
commit c086f49cea

View file

@ -121,7 +121,11 @@ def get_index_html (urls):
lines = ["<html>", "<body>"]
for entry in urls:
name = cgi.escape(entry)
url = cgi.escape(urllib.quote(entry))
try:
url = cgi.escape(urllib.quote(entry))
except KeyError:
# Some unicode entries raise KeyError.
url = name
lines.append('<a href="%s">%s</a>' % (url, name))
lines.extend(["</body>", "</html>"])
return os.linesep.join(lines)