Skip to content

fix: properly quote volume paths with spaces in docker run output#139

Open
BlocksecPHD wants to merge 1 commit intolavie:masterfrom
BlocksecPHD:master
Open

fix: properly quote volume paths with spaces in docker run output#139
BlocksecPHD wants to merge 1 commit intolavie:masterfrom
BlocksecPHD:master

Conversation

@BlocksecPHD
Copy link
Copy Markdown

Summary

Fixes issue #134 - containers with volumes containing spaces would generate broken docker run commands.

Root Cause

The parse_volumes() function in inspector.py was not quoting volume paths, causing commands to break when paths contain spaces.

Example from issue #134:

--volume /volume1/homes/JEREMYMEYERS/Drive/Backup/Music Drive/P/Sound Files:/music

The space in "Music Drive" would break the generated command.

Fix

Modified parse_volumes() to use shlex.quote() (already imported) for all volume paths:

# Before
volume_format = f'{mount["Source"]}:{mount["Destination"]}'

# After  
volume_format = f'{quote(mount["Source"])}:{quote(mount["Destination"])}'

This ensures:

  • Paths with spaces are properly quoted: '/path/with spaces':/dest
  • Normal paths without special characters remain unquoted: /normal/path:/dest

Testing

Added unit tests in test_runlike.py:

  • test_quote_path_with_spaces: verifies quoting behavior
  • test_quote_normal_path: verifies no unnecessary quoting
  • test_parse_volumes_with_spaces: verifies Inspector correctly handles paths with spaces

All tests pass.

Example

# Before fix
--volume /volume1/homes/Backup/Music Drive/P/Sound Files:/music

# After fix  
--volume '/volume1/homes/Backup/Music Drive/P/Sound Files':/music

Fixes #134

Fixes issue lavie#134 - containers with volumes containing spaces would
generate broken docker run commands. The volume paths are now properly
quoted using shlex.quote() to ensure shell-safe output.

Changes:
- Modified parse_volumes() in inspector.py to quote all volume paths
- Added unit tests for the quoting behavior

The fix ensures that paths like '/path/with spaces/folder' are output
as '/path/with spaces/folder' instead of breaking the command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Containers with volumes containing spaces break the conversion

1 participant