aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mitmproxy/net/check.py3
-rw-r--r--test/mitmproxy/net/test_check.py2
2 files changed, 4 insertions, 1 deletions
diff --git a/mitmproxy/net/check.py b/mitmproxy/net/check.py
index 7b007cb5..f793d397 100644
--- a/mitmproxy/net/check.py
+++ b/mitmproxy/net/check.py
@@ -1,6 +1,7 @@
import re
-_label_valid = re.compile(b"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
+# Allow underscore in host name
+_label_valid = re.compile(b"(?!-)[A-Z\d\-_]{1,63}(?<!-)$", re.IGNORECASE)
def is_valid_host(host: bytes) -> bool:
diff --git a/test/mitmproxy/net/test_check.py b/test/mitmproxy/net/test_check.py
index 18a50157..36dca168 100644
--- a/test/mitmproxy/net/test_check.py
+++ b/test/mitmproxy/net/test_check.py
@@ -8,3 +8,5 @@ def test_is_valid_host():
assert check.is_valid_host(b"one.two")
assert not check.is_valid_host(b"one" * 255)
assert check.is_valid_host(b"one.two.")
+ # Allow underscore
+ assert check.is_valid_host(b"one_two")