From: Fredrik Tolf Date: Wed, 18 Sep 2013 04:38:31 +0000 (+0200) Subject: Merge branch 'master' into python3 X-Git-Url: http://dolda2000.com/gitweb/?p=wrw.git;a=commitdiff_plain;h=199cdc4055921d7497e5a6b9a132ac44d04e9894;hp=84a8cc4a9a8e91dfe0dcb245474af32d3a5dc613 Merge branch 'master' into python3 --- diff --git a/wrw/proto.py b/wrw/proto.py index 96a8878..0e49379 100644 --- a/wrw/proto.py +++ b/wrw/proto.py @@ -103,10 +103,12 @@ def simpleerror(env, startreq, code, title, msg): return [buf] def urlq(url): + if isinstance(url, unicode): + url = url.encode("utf-8") ret = "" invalid = "&=#?/\"'" for c in url: - if c in invalid or (ord(c) <= 32): + if c in invalid or (ord(c) <= 32) or (ord(c) >= 128): ret += "%%%02X" % ord(c) else: ret += c diff --git a/wrw/sp/util.py b/wrw/sp/util.py index ad99e8b..0728a7e 100644 --- a/wrw/sp/util.py +++ b/wrw/sp/util.py @@ -235,5 +235,7 @@ class response(dispatch.restart): raise Exception("a subclass of wrw.sp.util.response must override ctype") def handle(self, req): + ret = self.formatter.format(self.root, doctype=self.doctype, charset=self.charset) req.ohead["Content-Type"] = self.ctype - return [self.formatter.format(self.root, doctype=self.doctype, charset=self.charset)] + req.ohead["Content-Length"] = len(ret) + return [ret]