aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/net
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2018-03-04 19:53:15 +0100
committerGitHub <noreply@github.com>2018-03-04 19:53:15 +0100
commita2740ee4aec5bd6258a0d9c17d58b7ef7d2ed3ee (patch)
tree427098361e6193b8e9e6e06c22f356eb4e8fbdaf /mitmproxy/net
parent618d52a65e79e06441b3e6672c4b11317201e46e (diff)
parentfb54bb377763b4e57c1a092610d83a2b9ac4e6e9 (diff)
downloadmitmproxy-a2740ee4aec5bd6258a0d9c17d58b7ef7d2ed3ee.tar.gz
mitmproxy-a2740ee4aec5bd6258a0d9c17d58b7ef7d2ed3ee.tar.bz2
mitmproxy-a2740ee4aec5bd6258a0d9c17d58b7ef7d2ed3ee.zip
Merge pull request #2868 from kira0204/data-crash
Fix crashing when editing form with random data, fix #2794
Diffstat (limited to 'mitmproxy/net')
-rw-r--r--mitmproxy/net/http/request.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/mitmproxy/net/http/request.py b/mitmproxy/net/http/request.py
index 6b4041f6..959fdd33 100644
--- a/mitmproxy/net/http/request.py
+++ b/mitmproxy/net/http/request.py
@@ -429,10 +429,7 @@ class Request(message.Message):
def _get_urlencoded_form(self):
is_valid_content_type = "application/x-www-form-urlencoded" in self.headers.get("content-type", "").lower()
if is_valid_content_type:
- try:
- return tuple(mitmproxy.net.http.url.decode(self.content.decode()))
- except ValueError:
- pass
+ return tuple(mitmproxy.net.http.url.decode(self.get_text(strict=False)))
return ()
def _set_urlencoded_form(self, form_data):
@@ -441,7 +438,7 @@ class Request(message.Message):
This will overwrite the existing content if there is one.
"""
self.headers["content-type"] = "application/x-www-form-urlencoded"
- self.content = mitmproxy.net.http.url.encode(form_data, self.content.decode()).encode()
+ self.content = mitmproxy.net.http.url.encode(form_data, self.get_text(strict=False)).encode()
@property
def urlencoded_form(self):