diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-05 11:27:40 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-05 11:27:40 +1200 |
commit | 4acc9aca273aad2e804126cc1e6c602c13f5c976 (patch) | |
tree | 115a58c75039c6f69f8919373ea7706328022722 /libmproxy/console/grideditor.py | |
parent | 837fcc65f53eb60b87987df445d150b4b362d3e9 (diff) | |
download | mitmproxy-4acc9aca273aad2e804126cc1e6c602c13f5c976.tar.gz mitmproxy-4acc9aca273aad2e804126cc1e6c602c13f5c976.tar.bz2 mitmproxy-4acc9aca273aad2e804126cc1e6c602c13f5c976.zip |
Firm up handling of Unicode data
- Modify GridEditor to know about the destination encoding of data
- Ensure that get_url always returns ASCII
Diffstat (limited to 'libmproxy/console/grideditor.py')
-rw-r--r-- | libmproxy/console/grideditor.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libmproxy/console/grideditor.py b/libmproxy/console/grideditor.py index 371c8c57..51002e77 100644 --- a/libmproxy/console/grideditor.py +++ b/libmproxy/console/grideditor.py @@ -229,6 +229,10 @@ class GridListBox(urwid.ListBox): FIRST_WIDTH_MAX = 40 FIRST_WIDTH_MIN = 20 class GridEditor(common.WWrap): + title = None + columns = None + headings = None + encoding = None def __init__(self, master, value, callback, *cb_args, **cb_kwargs): value = copy.deepcopy(value) self.master, self.value, self.callback = master, value, callback @@ -299,7 +303,10 @@ class GridEditor(common.WWrap): res = [] for i in self.walker.lst: if any([x.strip() for x in i[0]]): - res.append(i[0]) + v = i[0] + if self.encoding: + v = [x.encode(self.encoding) for x in v] + res.append(v) self.callback(res, *self.cb_args, **self.cb_kwargs) self.master.pop_view() elif key in ["h", "left"]: @@ -334,18 +341,21 @@ class QueryEditor(GridEditor): title = "Editing query" columns = 2 headings = ("Key", "Value") + encoding = "ascii" class HeaderEditor(GridEditor): title = "Editing headers" columns = 2 headings = ("Key", "Value") + encoding = "ascii" class URLEncodedFormEditor(GridEditor): title = "Editing URL-encoded form" columns = 2 headings = ("Key", "Value") + encoding = "ascii" class ReplaceEditor(GridEditor): |