Skip to content

fix(WebServer): fix file transfer handling for paths with spaces#6

Merged
FASTSHIFT merged 1 commit intoFASTSHIFT:mainfrom
WangSimiao2000:FileTransferBugFix
Mar 3, 2026
Merged

fix(WebServer): fix file transfer handling for paths with spaces#6
FASTSHIFT merged 1 commit intoFASTSHIFT:mainfrom
WangSimiao2000:FileTransferBugFix

Conversation

@WangSimiao2000
Copy link
Contributor

Fix: File Transfer Handling for Paths with Spaces

Problem

The file transfer module failed to correctly handle file pathscontaining spaces, causing transfer failures when uploading/downloading files with spaces in their names or paths.

Changes

  • Modified file_transfer.py: Improved path parsing logic to properly handle spaces in file paths
  • Updated test_file_transfer.py: Fixed test compatibility
  • Added test_file_transfer_spaces.py:Comprehensive test suite (132 lines) covering:
    • File paths with single/multiple spaces
    • Directory paths with spaces
    • Edge cases for space handling

Testing

All new tests pass, ensuring robust handling of:

  • Upload/download with spaces in filenames
  • Paths with multiple consecutive spaces
  • Mixed scenarios with spaces in directory and file names

Impact

  • Fixes file transfer failures for paths containing spaces
  • Improves reliability of the WebServer file transfer feature
  • No breaking changes to existing functionality

@FASTSHIFT FASTSHIFT changed the title Fix file transfer handling for paths with spaces fix(WebServer): fix file transfer handling for paths with spaces Feb 28, 2026
@FASTSHIFT FASTSHIFT requested a review from Copilot February 28, 2026 06:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes WebServer file transfer failures when remote paths contain spaces by quoting --path/--newpath arguments in FileTransfer commands and updating fstat response parsing to handle spaced paths, with accompanying test updates and a new test suite.

Changes:

  • Quote file path arguments for fopen/fstat/flist/fremove/fmkdir/frename command generation.
  • Update fstat parsing regex to capture paths that may contain spaces.
  • Add/adjust unit tests to validate path quoting behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Tools/WebServer/core/file_transfer.py Quotes --path arguments and adjusts fstat parsing to support spaced paths.
Tools/WebServer/tests/test_file_transfer.py Updates rename test expectation to match newly quoted paths.
Tools/WebServer/tests/test_file_transfer_spaces.py Adds tests covering file operations where paths include spaces.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…prevent command injection

- Add path sanitization to reject control characters (\r, \n)
- Escape double quotes in paths to prevent command injection
- Add comprehensive security tests for path validation
- All 128 tests pass
@FASTSHIFT FASTSHIFT merged commit 30d2143 into FASTSHIFT:main Mar 3, 2026
2 of 3 checks passed
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.

3 participants