mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 14:58:38 +00:00
Firm up handling of Unicode data
- Modify GridEditor to know about the destination encoding of data - Ensure that get_url always returns ASCII
This commit is contained in:
parent
837fcc65f5
commit
4acc9aca27
@ -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):
|
||||
|
@ -359,7 +359,7 @@ class Request(HTTPMsg):
|
||||
"""
|
||||
Returns a URL string, constructed from the Request's URL compnents.
|
||||
"""
|
||||
return utils.unparse_url(self.scheme, self.host.decode("idna"), self.port, self.path)
|
||||
return utils.unparse_url(self.scheme, self.host.decode("idna"), self.port, self.path).encode('ascii')
|
||||
|
||||
def set_url(self, url):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user