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

%s

+

%s

+ + +""" % (title, title, htmlq(msg)) + 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