From f351d0a3079d88d98934b7e9a48c2ffb4a3018a0 Mon Sep 17 00:00:00 2001 From: dequis Date: Tue, 14 Mar 2017 01:54:31 -0300 Subject: [PATCH] Match ~d and ~u filters against pretty_host too Changed the ~u filter in the console UI to match the behavior of mitmweb, which only matches against pretty_url, never against url. --- mitmproxy/flowfilter.py | 8 ++++++-- web/src/js/filt/filt.peg | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index 7c4f95f70..2c7fc52f4 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -319,10 +319,14 @@ class FDomain(_Rex): code = "d" help = "Domain" flags = re.IGNORECASE + is_binary = False @only(http.HTTPFlow) def __call__(self, f): - return bool(self.re.search(f.request.data.host)) + return bool( + self.re.search(f.request.host) or + self.re.search(f.request.pretty_host) + ) class FUrl(_Rex): @@ -339,7 +343,7 @@ class FUrl(_Rex): @only(http.HTTPFlow) def __call__(self, f): - return self.re.search(f.request.url) + return self.re.search(f.request.pretty_url) class FSrc(_Rex): diff --git a/web/src/js/filt/filt.peg b/web/src/js/filt/filt.peg index b2576661d..129594741 100644 --- a/web/src/js/filt/filt.peg +++ b/web/src/js/filt/filt.peg @@ -96,7 +96,7 @@ function responseBody(regex){ function domain(regex){ regex = new RegExp(regex, "i"); function domainFilter(flow){ - return flow.request && regex.test(flow.request.host); + return flow.request && (regex.test(flow.request.host) || regex.test(flow.request.pretty_host)); } domainFilter.desc = "domain matches " + regex; return domainFilter;