Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape file names passed through ssh #1450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions labgrid/driver/usbstoragedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pathlib
import time
import subprocess
import shlex

import attr

Expand Down Expand Up @@ -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
Expand Down
Loading