From 05f7760a01c445f3bea559cff3ab40d7a71038f7 Mon Sep 17 00:00:00 2001 From: Florian Hars Date: Thu, 25 Jul 2024 11:04:08 +0200 Subject: [PATCH] escape file names passed through ssh fixes #1392 Signed-off-by: Florian Hars --- labgrid/driver/usbstoragedriver.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/labgrid/driver/usbstoragedriver.py b/labgrid/driver/usbstoragedriver.py index 5ceec293d..88ba95dda 100644 --- a/labgrid/driver/usbstoragedriver.py +++ b/labgrid/driver/usbstoragedriver.py @@ -3,6 +3,7 @@ import pathlib import time import subprocess +import shlex import attr @@ -96,14 +97,14 @@ def write_files(self, sources, target, partition, target_is_directory=True): # (pathlib.PurePath(...) / "/") == "/", so we turn absolute paths into relative # paths with respect to the mount point here target_rel = target.relative_to(target.root) if target.root is not None else target - target_path = str(pathlib.PurePath(mount_path) / target_rel) + target_path = shlex.quote(str(pathlib.PurePath(mount_path) / target_rel)) copied_sources = [] for f in sources: mf = ManagedFile(f, self.storage) mf.sync_to_resource() - copied_sources.append(mf.get_remote_path()) + copied_sources.append(shlex.quote(mf.get_remote_path())) if target_is_directory: args = ["cp", "-t", target_path] + copied_sources