Skip to content

fix: sanitize filenames for cross-platform compatibility#93

Merged
flexiondotorg merged 1 commit intomainfrom
sanitise
Jan 22, 2026
Merged

fix: sanitize filenames for cross-platform compatibility#93
flexiondotorg merged 1 commit intomainfrom
sanitise

Conversation

@flexiondotorg
Copy link
Member

@flexiondotorg flexiondotorg commented Jan 22, 2026

  • Add sanitize_filename() function to utils.rs that replaces invalid filesystem characters (< > : " | ? * and control characters) with underscores
  • Handle Windows reserved names (CON, PRN, AUX, NUL, COM1-9, LPT1-9) by inserting underscore before extension
  • Preserve directory structure in filenames with path separators
  • Trim leading/trailing spaces and trailing dots from path components
  • Apply sanitization in main.rs before downloading files
  • Display warnings when filenames are modified with before/after
  • Show summary count of sanitized files
  • Add comprehensive unit tests covering edge cases

Fixes #63


Summary by cubic

Sanitizes filenames before download to ensure cross-platform compatibility and prevent filesystem errors (fixes #63).

  • Bug Fixes
    • Replace invalid characters (< > : " | ? * \ and control chars) with underscores.
    • Handle Windows reserved names (CON, PRN, AUX, NUL, COM1–9, LPT1–9) by adding an underscore before the extension.
    • Trim leading/trailing spaces and trailing dots in each path part; preserve path separators.
    • Apply sanitization in main.rs before downloads; warn per file and show a total count.
    • Add unit tests covering edge cases.

Written for commit b476e8a. Summary will update on new commits.

- Add sanitize_filename() function to utils.rs that replaces invalid
  filesystem characters (< > : " | ? * and control characters) with
  underscores
- Handle Windows reserved names (CON, PRN, AUX, NUL, COM1-9, LPT1-9)
  by inserting underscore before extension
- Preserve directory structure in filenames with path separators
- Trim leading/trailing spaces and trailing dots from path components
- Apply sanitization in main.rs before downloading files
- Display warnings when filenames are modified with before/after
- Show summary count of sanitized files
- Add comprehensive unit tests covering edge cases

Fixes #63
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@flexiondotorg flexiondotorg merged commit b8b7076 into main Jan 22, 2026
5 checks passed
@flexiondotorg flexiondotorg deleted the sanitise branch January 22, 2026 10:06
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.

Skipping syntax errors.

1 participant