From 79bbc41cb458ffd19b09e957e9b562befbad58b9 Mon Sep 17 00:00:00 2001 From: arjun23496 Date: Fri, 26 Aug 2016 12:13:34 +0530 Subject: [PATCH 1/3] Fixes #1471 - Change .* to match entire body --- mitmproxy/builtins/replace.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mitmproxy/builtins/replace.py b/mitmproxy/builtins/replace.py index c938d6838..a5dae33e1 100644 --- a/mitmproxy/builtins/replace.py +++ b/mitmproxy/builtins/replace.py @@ -36,9 +36,9 @@ class Replace: for rex, s, cpatt in self.lst: if cpatt(f): if f.response: - f.response.replace(rex, s) + f.response.replace(rex, s, re.DOTALL) else: - f.request.replace(rex, s) + f.request.replace(rex, s, re.DOTALL) def request(self, flow): if not flow.reply.has_message: From f6ed06bf16329f075b52b89f2fdfb061bb1355c1 Mon Sep 17 00:00:00 2001 From: arjun23496 Date: Fri, 26 Aug 2016 12:46:43 +0530 Subject: [PATCH 2/3] Convert to flags=value for future compatibility --- mitmproxy/builtins/replace.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mitmproxy/builtins/replace.py b/mitmproxy/builtins/replace.py index a5dae33e1..df3cab043 100644 --- a/mitmproxy/builtins/replace.py +++ b/mitmproxy/builtins/replace.py @@ -36,9 +36,9 @@ class Replace: for rex, s, cpatt in self.lst: if cpatt(f): if f.response: - f.response.replace(rex, s, re.DOTALL) + f.response.replace(rex, s, flags=re.DOTALL) else: - f.request.replace(rex, s, re.DOTALL) + f.request.replace(rex, s, flags=re.DOTALL) def request(self, flow): if not flow.reply.has_message: From 2e1265f75ebfc59eac38d6cfa4839d8d10165ace Mon Sep 17 00:00:00 2001 From: arjun23496 Date: Fri, 9 Sep 2016 10:46:16 +0530 Subject: [PATCH 3/3] Changed filter to match replacement for DOTALL --- mitmproxy/filt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mitmproxy/filt.py b/mitmproxy/filt.py index 67915e5b6..eb3e392bf 100644 --- a/mitmproxy/filt.py +++ b/mitmproxy/filt.py @@ -244,6 +244,7 @@ class FHeadResponse(_Rex): class FBod(_Rex): code = "b" help = "Body" + flags = re.DOTALL @only(HTTPFlow, TCPFlow) def __call__(self, f): @@ -264,6 +265,7 @@ class FBod(_Rex): class FBodRequest(_Rex): code = "bq" help = "Request body" + flags = re.DOTALL @only(HTTPFlow, TCPFlow) def __call__(self, f): @@ -280,6 +282,7 @@ class FBodRequest(_Rex): class FBodResponse(_Rex): code = "bs" help = "Response body" + flags = re.DOTALL @only(HTTPFlow, TCPFlow) def __call__(self, f):