aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2014-01-19 13:23:38 +1300
committerAldo Cortesi <aldo@nullcube.com>2014-01-19 13:23:38 +1300
commitbf1399fa2bc2f34a480a27f2a8ec98f2e479ddc2 (patch)
treee4fcc9e3adacff50ec38e62b2ec1923f26f56d6e
parentf5f46bf0808a5c7d5f9ed89d02a4714bcb66bf43 (diff)
downloadmitmproxy-bf1399fa2bc2f34a480a27f2a8ec98f2e479ddc2.tar.gz
mitmproxy-bf1399fa2bc2f34a480a27f2a8ec98f2e479ddc2.tar.bz2
mitmproxy-bf1399fa2bc2f34a480a27f2a8ec98f2e479ddc2.zip
Handle views that don't support search gracefully
This includes all key/value formatted views, e.g. the image view. We need to support these ultimately, but no time before the next release.
-rw-r--r--libmproxy/console/flowview.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py
index 45d57721..6c4a2651 100644
--- a/libmproxy/console/flowview.py
+++ b/libmproxy/console/flowview.py
@@ -3,6 +3,10 @@ import urwid
import common, grideditor, contentview
from .. import utils, flow, controller
+
+class SearchError(Exception): pass
+
+
def _mkhelp():
text = []
keys = [
@@ -296,7 +300,10 @@ class FlowView(common.WWrap):
# generate the body, highlight the words and get focus
headers, msg, body = self.conn_text_raw(text)
- body, focus_position = self.search_highlight_text(body, search_string)
+ try:
+ body, focus_position = self.search_highlight_text(body, search_string)
+ except SearchError:
+ return "Search not supported in this view."
if focus_position == None:
# no results found.
@@ -347,8 +354,10 @@ class FlowView(common.WWrap):
if i != start_line:
start_index = 0
- text, style = text_object.get_text()
-
+ try:
+ text, style = text_object.get_text()
+ except AttributeError:
+ raise SearchError()
find_index = text.find(search_string, start_index)
if find_index != -1:
before = text[:find_index]