Make formparse not depend on input being a limitreader.
authorFredrik Tolf <fredrik@dolda2000.com>
Wed, 23 Apr 2014 03:02:39 +0000 (05:02 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Wed, 23 Apr 2014 03:02:39 +0000 (05:02 +0200)
wrw/form.py

index adde1d3..a57a812 100644 (file)
@@ -7,9 +7,9 @@ def formparse(req):
     buf = {}
     buf.update(urllib.parse.parse_qsl(req.query))
     if req.ihead.get("Content-Type") == "application/x-www-form-urlencoded":
-        if req.input.limit > 2 ** 20:
+        rbody = req.input(2 ** 20)
+        if len(rbody) >= 2 ** 20:
             raise ValueError("x-www-form-urlencoded data is absurdly long")
-        rbody = req.input.read()
         buf.update(urllib.parse.parse_qsl(rbody.decode("latin1")))
     return buf