From f78dada550dac02ea1dc69a7a00fcdfc7a8c996f Mon Sep 17 00:00:00 2001 From: "Jason A. Novak" Date: Sun, 21 Apr 2013 12:46:37 -0500 Subject: [PATCH] Add error checking to ViewProtobuf There are protobufs that protoc can't parse. When protoc --decode_raw fails, it returns nothing to stdin, and writes "Failed to parse input." to stderr. Before this commit, if protoc --decode_raw couldn't parse the protobuf, the blank stdout output would get returned to the view; with this commit stderr gets caught and returned to the view. --- libmproxy/console/contentview.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py index 53841c736..8dd8ad1d3 100644 --- a/libmproxy/console/contentview.py +++ b/libmproxy/console/contentview.py @@ -389,8 +389,11 @@ class ViewProtobuf: stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, _ = p.communicate(input=content) - return out + out, err = p.communicate(input=content) + if out: + return out + else: + return err def __call__(self, hdrs, content, limit): decoded = self.decode_protobuf(content)