def execute(self, cmdstr: str) -> typing.Any: """ Execute a command string. May raise CommandError. """ parts, _ = self.parse_partial(cmdstr) if not parts: raise exceptions.CommandError(f"Invalid command: {cmdstr!r}") command_name, *args = [ unquote(part.value) for part in parts if part.type != mitmproxy.types.Space ] return self.call_strings(command_name, args)
def test_quote_unquote_cycle(s): assert command_lexer.unquote(command_lexer.quote(s)) == s
def test_unquote_never_fails(s): command_lexer.unquote(s)
def test_quote_unquote_cycle(s): assert command_lexer.unquote(command_lexer.quote(s)).replace(r"\x22", '"') == s