diff --git a/CHANGELOG.md b/CHANGELOG.md index b47e55ff0..30713bb06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ ([#6543](https://github.com/mitmproxy/mitmproxy/pull/6543), @mhils) * DNS resolution is now exempted from `--ignore-hosts` in WireGuard Mode. ([#6513](https://github.com/mitmproxy/mitmproxy/pull/6513), @dsphper) +* Fix case sensitivity of URL added to blocklist + ([#6493](https://github.com/mitmproxy/mitmproxy/pull/6493), @emanuele-em) * Fix a bug where logging was stopped prematurely during shutdown. ([#6541](https://github.com/mitmproxy/mitmproxy/pull/6541), @mhils) * For plaintext traffic, `--ignore-hosts` now also takes HTTP/1 host headers into account. diff --git a/mitmproxy/flowfilter.py b/mitmproxy/flowfilter.py index 52db22be0..840583f3d 100644 --- a/mitmproxy/flowfilter.py +++ b/mitmproxy/flowfilter.py @@ -402,6 +402,7 @@ class FUrl(_Rex): code = "u" help = "URL" is_binary = False + flags = re.IGNORECASE # FUrl is special, because it can be "naked". diff --git a/test/mitmproxy/addons/test_blocklist.py b/test/mitmproxy/addons/test_blocklist.py index 9187443b2..b7c7e536d 100644 --- a/test/mitmproxy/addons/test_blocklist.py +++ b/test/mitmproxy/addons/test_blocklist.py @@ -22,20 +22,21 @@ def test_parse_spec_err(filter, err): class TestBlockList: @pytest.mark.parametrize( - "filter,status_code", + "filter,request_url,status_code", [ - (":~u example.org:404", 404), - (":~u example.com:404", None), - ("/!jpg/418", None), - ("/!png/418", 418), + (":~u example.org:404", b"https://example.org/images/test.jpg", 404), + (":~u example.com:404", b"https://example.org/images/test.jpg", None), + (":~u test:404", b"https://example.org/images/TEST.jpg", 404), + ("/!jpg/418", b"https://example.org/images/test.jpg", None), + ("/!png/418", b"https://example.org/images/test.jpg", 418), ], ) - def test_block(self, filter, status_code): + def test_block(self, filter, request_url, status_code): bl = blocklist.BlockList() with taddons.context(bl) as tctx: tctx.configure(bl, block_list=[filter]) f = tflow.tflow() - f.request.url = b"https://example.org/images/test.jpg" + f.request.url = request_url bl.request(f) if status_code is not None: assert f.response.status_code == status_code