aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-02-24 13:03:24 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-02-24 13:03:24 +1300
commit25fa596cd6aa6468d1a7dd5d8c2fc5bfc7cef004 (patch)
tree084ae29e13bfa8faec401a5059a6967a64833597 /libmproxy
parentddc9155c243f9ccb463a84f259837ef79d607d66 (diff)
downloadmitmproxy-25fa596cd6aa6468d1a7dd5d8c2fc5bfc7cef004.tar.gz
mitmproxy-25fa596cd6aa6468d1a7dd5d8c2fc5bfc7cef004.tar.bz2
mitmproxy-25fa596cd6aa6468d1a7dd5d8c2fc5bfc7cef004.zip
Fix detection of URL-encoded forms.
Thanks to Paul Capestany <capestany@gmail.com> for reporting this.
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/flow.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index e010883a..58e4eea4 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -146,6 +146,21 @@ class ODict:
elements.append("")
return "\r\n".join(elements)
+ def in_any(self, key, value, caseless=False):
+ """
+ Do any of the values matching key contain value?
+
+ If caseless is true, value comparison is case-insensitive.
+ """
+ if caseless:
+ value = value.lower()
+ for i in self[key]:
+ if caseless:
+ i = i.lower()
+ if value in i:
+ return True
+ return False
+
def match_re(self, expr):
"""
Match the regular expression against each (key, value) pair. For
@@ -347,8 +362,7 @@ class Request(HTTPMsg):
Returns an empty ODict if there is no data or the content-type
indicates non-form data.
"""
- hv = [i.lower() for i in self.headers["content-type"]]
- if HDR_FORM_URLENCODED in hv:
+ if self.headers.in_any("content-type", HDR_FORM_URLENCODED, True):
return ODict(utils.urldecode(self.content))
return ODict([])