From 4acc9aca273aad2e804126cc1e6c602c13f5c976 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 5 Jul 2012 11:27:40 +1200 Subject: Firm up handling of Unicode data - Modify GridEditor to know about the destination encoding of data - Ensure that get_url always returns ASCII --- libmproxy/console/grideditor.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libmproxy/console/grideditor.py') 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): -- cgit v1.2.3