X-Git-Url: http://dolda2000.com/gitweb/?p=wrw.git;a=blobdiff_plain;f=wrw%2Fproto.py;h=482a23ead18d2bef26a415ab22a990ae1680f46d;hp=3dcf0d7a31d4c4ae8ab26c90a4db68c4df193427;hb=69eb6cbefcf769276e3e15c6f20e9d5af74fd326;hpb=87f2697cdea2cca6eb6cae7f1ff5e46a5d8133a3 diff --git a/wrw/proto.py b/wrw/proto.py index 3dcf0d7..482a23e 100644 --- a/wrw/proto.py +++ b/wrw/proto.py @@ -98,19 +98,20 @@ def simpleerror(env, startreq, code, title, msg): """ % (title, title, htmlq(msg)) + buf = buf.encode("us-ascii") startreq("%i %s" % (code, title), [("Content-Type", "text/html"), ("Content-Length", str(len(buf)))]) return [buf] def urlq(url): - if isinstance(url, unicode): + if isinstance(url, str): url = url.encode("utf-8") ret = "" - invalid = "&=#?/\"'" + invalid = b"%;&=#?/\"'" for c in url: - if c in invalid or (ord(c) <= 32) or (ord(c) >= 128): - ret += "%%%02X" % ord(c) + if c in invalid or (c <= 32) or (c >= 128): + ret += "%%%02X" % c else: - ret += c + ret += chr(c) return ret class urlerror(ValueError):