diff options
| author | ColdFire <9128903+fenilgandhi@users.noreply.github.com> | 2018-02-23 23:25:14 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-23 23:25:14 +0530 |
| commit | 8008e25527be3322f97a8eb87369e30ccc1ff48d (patch) | |
| tree | 8f26c321961bcee0fa10750c42ed2e5abc1d9bbd /mitmproxy | |
| parent | 777cb98a86f3e8883383935661e2ed20ed9b6bd4 (diff) | |
| parent | 18384eecbd8fafca87d7ecaa79d366a5df1063e0 (diff) | |
| download | mitmproxy-8008e25527be3322f97a8eb87369e30ccc1ff48d.tar.gz mitmproxy-8008e25527be3322f97a8eb87369e30ccc1ff48d.tar.bz2 mitmproxy-8008e25527be3322f97a8eb87369e30ccc1ff48d.zip | |
Merge branch 'master' into issue-2872
Diffstat (limited to 'mitmproxy')
| -rw-r--r-- | mitmproxy/tools/console/commander/commander.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/mitmproxy/tools/console/commander/commander.py b/mitmproxy/tools/console/commander/commander.py index 566c42e6..f3e499f8 100644 --- a/mitmproxy/tools/console/commander/commander.py +++ b/mitmproxy/tools/console/commander/commander.py @@ -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 |
