diff --git a/moonraker/plugins/file_manager.py b/moonraker/plugins/file_manager.py index a377605..f0ae10e 100644 --- a/moonraker/plugins/file_manager.py +++ b/moonraker/plugins/file_manager.py @@ -373,8 +373,7 @@ class FileManager: full_path = root_path dir_path = "" else: - parts = os.path.split(upload['filename'].strip().lstrip("/")) - filename = os.path.join(parts[0], "_".join(parts[1].split())) + filename = upload['filename'].strip().lstrip("/") if dir_path: filename = os.path.join(dir_path, filename) full_path = os.path.normpath(os.path.join(root_path, filename)) @@ -653,8 +652,11 @@ class MetadataStorage: self.busy = False async def _run_extract_metadata(self, filename, notify): + # Escape single quotes in the file name so that it may be + # properly loaded + filename = filename.replace("\"", "\\\"") cmd = " ".join([sys.executable, METADATA_SCRIPT, "-p", - self.gc_path, "-f", "'" + filename + "'"]) + self.gc_path, "-f", f"\"{filename}\""]) shell_command = self.server.lookup_plugin('shell_command') scmd = shell_command.build_shell_command( cmd, self._handle_script_response) diff --git a/moonraker/plugins/klippy_apis.py b/moonraker/plugins/klippy_apis.py index 573e928..cdea107 100644 --- a/moonraker/plugins/klippy_apis.py +++ b/moonraker/plugins/klippy_apis.py @@ -80,6 +80,8 @@ class KlippyAPI: # XXX - validate that file is on disk if filename[0] == '/': filename = filename[1:] + # Escape existing double quotes in the file name + filename = filename.replace("\"", "\\\"") script = f'SDCARD_PRINT_FILE FILENAME="{filename}"' return await self.run_gcode(script) diff --git a/moonraker/plugins/paneldue.py b/moonraker/plugins/paneldue.py index b6c4f34..fd64c81 100644 --- a/moonraker/plugins/paneldue.py +++ b/moonraker/plugins/paneldue.py @@ -451,6 +451,8 @@ class PanelDue: def _prepare_M32(self, args): filename = self._clean_filename(args[0]) + # Escape existing double quotes in the file name + filename = filename.replace("\"", "\\\"") return f"SDCARD_PRINT_FILE FILENAME=\"{filename}\"" def _prepare_M98(self, args):