Merge branch 'master' into issue-2872

This commit is contained in:
ColdFire 2018-02-23 23:25:14 +05:30 committed by GitHub
commit 8008e25527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 4 deletions

View File

@ -1,3 +1,7 @@
23 February 2018: mitmproxy 3.0
* Fix a quote-related issue affecting the mitmproxy console command prompt
22 February 2018: mitmproxy 3.0
** Major Changes **

View File

@ -68,6 +68,21 @@ class CommandBuffer:
else:
self._cursor = x
def maybequote(self, value):
if " " in value and not value.startswith("\""):
return "\"%s\"" % value
return value
def parse_quoted(self, txt):
parts, remhelp = self.master.commands.parse_partial(txt)
for i, p in enumerate(parts):
parts[i] = mitmproxy.command.ParseResult(
value = self.maybequote(p.value),
type = p.type,
valid = p.valid
)
return parts, remhelp
def render(self):
"""
This function is somewhat tricky - in order to make the cursor
@ -75,7 +90,7 @@ class CommandBuffer:
character-for-character offset match in the rendered output, up
to the cursor. Beyond that, we can add stuff.
"""
parts, remhelp = self.master.commands.parse_partial(self.text)
parts, remhelp = self.parse_quoted(self.text)
ret = []
for p in parts:
if p.valid:
@ -95,8 +110,9 @@ class CommandBuffer:
return ret
def flatten(self, txt):
parts, _ = self.master.commands.parse_partial(txt)
return " ".join([x.value for x in parts])
parts, _ = self.parse_quoted(txt)
ret = [x.value for x in parts]
return " ".join(ret)
def left(self) -> None:
self.cursor = self.cursor - 1

View File

@ -75,7 +75,7 @@ setup(
"pyasn1>=0.3.1,<0.5",
"pyOpenSSL>=17.5,<17.6",
"pyparsing>=2.1.3, <2.3",
"pyperclip>=1.5.22, <1.7",
"pyperclip>=1.6.0, <1.7",
"requests>=2.9.1, <3",
"ruamel.yaml>=0.13.2, <0.16",
"sortedcontainers>=1.5.4, <1.6",

View File

@ -211,6 +211,22 @@ class TestCommand:
],
[]
],
[
"flow \"one two",
[
command.ParseResult(value = "flow", type = mitmproxy.types.Cmd, valid = True),
command.ParseResult(value = "\"one two", type = flow.Flow, valid = False),
],
["str"]
],
[
"flow \"one two\"",
[
command.ParseResult(value = "flow", type = mitmproxy.types.Cmd, valid = True),
command.ParseResult(value = "one two", type = flow.Flow, valid = False),
],
["str"]
],
]
with taddons.context() as tctx:
tctx.master.addons.add(TAddon())