aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-06-12 16:00:16 +1200
committerAldo Cortesi <aldo@nullcube.com>2015-06-12 16:00:16 +1200
commit7890450b0c9d0cd95a2e5f507a9a8247702051be (patch)
tree8741042730f9e9a5e5eb28f99f3bf70e1e9274a8 /libmproxy/protocol
parentfcc15581808859b3d6670829c2d5248483660839 (diff)
downloadmitmproxy-7890450b0c9d0cd95a2e5f507a9a8247702051be.tar.gz
mitmproxy-7890450b0c9d0cd95a2e5f507a9a8247702051be.tar.bz2
mitmproxy-7890450b0c9d0cd95a2e5f507a9a8247702051be.zip
Handle invalid IDNA encoding in hostnames
Fixes #622
Diffstat (limited to 'libmproxy/protocol')
-rw-r--r--libmproxy/protocol/http.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index 91e74567..9c143386 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -584,11 +584,10 @@ class HTTPRequest(HTTPMessage):
of the request, e.g. if an upstream proxy is in place
If hostheader is set to True, the Host: header will be used as
- additional (and preferred) data source. This is handy in transparent
- mode, where only the ip of the destination is known, but not the
- resolved name. This is disabled by default, as an attacker may spoof
- the host header to confuse an analyst.
-
+ additional (and preferred) data source. This is handy in
+ transparent mode, where only the IO of the destination is known,
+ but not the resolved name. This is disabled by default, as an
+ attacker may spoof the host header to confuse an analyst.
"""
host = None
if hostheader:
@@ -596,7 +595,10 @@ class HTTPRequest(HTTPMessage):
if not host:
host = self.host
if host:
- return host.encode("idna")
+ try:
+ return host.encode("idna")
+ except ValueError:
+ return host
else:
return None