From 5f0b5532bc9681c0fac8cfe821f49bff904d47be Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 29 Jul 2013 18:14:11 +1200 Subject: Show an error when attempting to decode invalid data. --- libmproxy/console/flowview.py | 3 ++- libmproxy/flow.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'libmproxy') diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py index 419bfbcd..61e8715b 100644 --- a/libmproxy/console/flowview.py +++ b/libmproxy/console/flowview.py @@ -576,7 +576,8 @@ class FlowView(common.WWrap): self.flow.backup() e = conn.headers.get_first("content-encoding", "identity") if e != "identity": - conn.decode() + if not conn.decode(): + self.master.statusbar.message("Could not decode - invalid data?") else: self.master.prompt_onekey( "Select encoding: ", diff --git a/libmproxy/flow.py b/libmproxy/flow.py index e5061dfb..c1d78be3 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -221,15 +221,21 @@ class HTTPMsg(StateObject): Decodes content based on the current Content-Encoding header, then removes the header. If there is no Content-Encoding header, no action is taken. + + Returns True if decoding succeeded, False otherwise. """ ce = self.headers.get_first("content-encoding") if not self.content or ce not in encoding.ENCODINGS: - return - self.content = encoding.decode( + return False + data = encoding.decode( ce, self.content ) + if data is None: + return False + self.content = data del self.headers["content-encoding"] + return True def encode(self, e): """ -- cgit v1.2.3