aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/app.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-23 15:38:06 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-23 15:38:06 +1200
commit3027aae142c12b123715e1cb0ecc770f00d27198 (patch)
tree2b7c7de9989560334cc4eeebfb6d1fbd74f02a6f /libpathod/app.py
parent5283bb250788326ad1722b703148800a66a36adf (diff)
downloadmitmproxy-3027aae142c12b123715e1cb0ecc770f00d27198.tar.gz
mitmproxy-3027aae142c12b123715e1cb0ecc770f00d27198.tar.bz2
mitmproxy-3027aae142c12b123715e1cb0ecc770f00d27198.zip
Use configured size limit to keep previews in check.
Diffstat (limited to 'libpathod/app.py')
-rw-r--r--libpathod/app.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/libpathod/app.py b/libpathod/app.py
index 21ae9e0d..4b5758a0 100644
--- a/libpathod/app.py
+++ b/libpathod/app.py
@@ -62,7 +62,6 @@ def onelog(lid):
return render_template("onelog.html", section="log", alog=l, lid=lid)
-SANITY = 1024*1024
@app.route('/preview')
def preview():
spec = request.args["spec"]
@@ -78,11 +77,8 @@ def preview():
args["syntaxerror"] = str(v)
args["marked"] = v.marked()
return render_template("preview.html", **args)
- if r.length() > SANITY:
- error = "Refusing to preview a response of %s bytes. This is for your own good."%r.length()
- args["error"] = error
- else:
- s = cStringIO.StringIO()
- r.serve(s)
- args["output"] = s.getvalue()
+
+ s = cStringIO.StringIO()
+ r.serve(s, check=app.config["pathod"].check_size)
+ args["output"] = s.getvalue()
return render_template("preview.html", **args)