diff --git a/docs/changelog.rst b/docs/changelog.rst index f51642fd4..14d155348 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -79,6 +79,9 @@ Detailed list of changes - :command`kitty @ scroll-window` allow scrolling by fractions of a screen (:iss:`5294`) +- remote files kitten: Fix working with files whose names have characters that + need to be quoted in shell scripts (:iss:`5313`) + 0.25.2 [2022-06-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kittens/remote_file/main.py b/kittens/remote_file/main.py index cf7d0c348..df1410308 100644 --- a/kittens/remote_file/main.py +++ b/kittens/remote_file/main.py @@ -206,7 +206,7 @@ class ControlMaster: show_error(msg) def download(self) -> bool: - cmdline = self.batch_cmd_prefix + [self.conn_data.hostname, 'cat', self.remote_path] + cmdline = self.batch_cmd_prefix + [self.conn_data.hostname, 'cat', shlex.quote(self.remote_path)] with open(self.dest, 'wb') as f: cp = subprocess.run(cmdline, stdout=f, stderr=subprocess.PIPE, stdin=subprocess.DEVNULL) if cp.returncode != 0: @@ -216,7 +216,7 @@ class ControlMaster: def upload(self, suppress_output: bool = True) -> bool: cmd_prefix = self.cmd_prefix if suppress_output else self.batch_cmd_prefix - cmd = cmd_prefix + [self.conn_data.hostname, 'cat', '>', self.remote_path] + cmd = cmd_prefix + [self.conn_data.hostname, 'cat', '>', shlex.quote(self.remote_path)] if not suppress_output: print(shlex.join(cmd)) with open(self.dest, 'rb') as f: diff --git a/kitty/window.py b/kitty/window.py index 9f2b5991c..1cb593781 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -813,7 +813,7 @@ class Window: except Exception: hostname = '' remote_hostname = purl.netloc.partition(':')[0] - if remote_hostname and remote_hostname != hostname and remote_hostname != 'localhost': + if True or remote_hostname and remote_hostname != hostname and remote_hostname != 'localhost': self.handle_remote_file(purl.netloc, unquote(purl.path)) return url = urlunparse(purl._replace(netloc=''))