From: Fredrik Tolf Date: Sat, 18 Feb 2023 22:17:25 +0000 (+0100) Subject: Parse POST form-data better. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=f6b73d8c8c488e25c726fd4e57b8cf72a61cccf1;hp=cbb2bf5852924803bdb13779dc0e8e88000925d6;p=wrw.git Parse POST form-data better. --- diff --git a/wrw/form.py b/wrw/form.py index f821ea1..902d759 100644 --- a/wrw/form.py +++ b/wrw/form.py @@ -6,14 +6,15 @@ __all__ = ["formdata"] def formparse(req): buf = {} buf.update(urllib.parse.parse_qsl(req.query, keep_blank_values=True)) - if req.ihead.get("Content-Type") == "application/x-www-form-urlencoded": + ctype, ctpars = proto.pmimehead(req.ihead.get("Content-Type", "")) + if ctype == "application/x-www-form-urlencoded": try: rbody = req.input.read(2 ** 20) except IOError as exc: return exc if len(rbody) >= 2 ** 20: return ValueError("x-www-form-urlencoded data is absurdly long") - buf.update(urllib.parse.parse_qsl(rbody.decode("latin1"), keep_blank_values=True)) + buf.update(urllib.parse.parse_qsl(rbody.decode("latin1"), encoding=ctparse.get("charset", "utf-8"), keep_blank_values=True)) return buf class badmultipart(IOError):