X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fproto.py;h=0e49379e391fb5e59a9f865f6a4a6078f92b6434;hb=199cdc4055921d7497e5a6b9a132ac44d04e9894;hp=8474b3a16e533b2d1cf702d1f7e5ab40eb07a1e7;hpb=b904defe1135d64ae7035b8903c221b0f022b98f;p=wrw.git diff --git a/wrw/proto.py b/wrw/proto.py index 8474b3a..0e49379 100644 --- a/wrw/proto.py +++ b/wrw/proto.py @@ -85,10 +85,30 @@ def htmlq(html): ret += c return ret +def simpleerror(env, startreq, code, title, msg): + buf = """ + + + +%s + + +

%s

+

%s

+ + +""" % (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): + url = url.encode("utf-8") ret = "" + invalid = "&=#?/\"'" for c in url: - if c == "&" or c == "=" or c == "#" or c == "?" or c == "/" or (ord(c) <= 32): + if c in invalid or (ord(c) <= 32) or (ord(c) >= 128): ret += "%%%02X" % ord(c) else: ret += c