X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fproto.py;h=cc2edb85d5665046395fd42566efe1ea28f0d220;hb=11c9628ee0bad3e74e60b040986edc59465f4675;hp=1af091f92fb44a5a3dc4aea4f05ab9aae605a096;hpb=cbb90a8de3bed03b68b6e537433c6e6d17ff52cb;p=wrw.git diff --git a/wrw/proto.py b/wrw/proto.py index 1af091f..cc2edb8 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):