Repository navigation
Suggest file names Windows accepts on every platform [patch] - #203
Merged
Merged
Conversation
SanitizeFileName replaced only Path.GetInvalidFileNameChars(), which is just "\0" and "/" on Linux and macOS, so a name suggested there kept : ? * < > | \ " and could not be used to rename on Windows, NTFS, SMB or exFAT, and made a JSON import on Windows abort. Replace a fixed, platform-independent set (those characters plus control characters) with "-", and suffix a Windows device name such as "con" so it does not become con.jpg. Fixes #171 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NwJrDAUtukhDgLo9pAfR3t
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #171
What was wrong
Scan.SanitizeFileNamereplaced onlyPath.GetInvalidFileNameChars(). On Linux and macOS that set is just\0and/, so"sunset at 5:30pm? <draft>"was stored unchanged. A name like that can't be used to rename a file on Windows, NTFS, SMB or exFAT, and a JSON export taken from Linux makesImporton Windows abort whenFileNamerejects it.Change
< > : " / \ | ? *and control characters 0–31, each replaced with-as before. The result is the same on every OS.CON,PRN,AUX,NUL,COM1–9,LPT1–9, case-insensitive), it gets an-imagesuffix, soconbecomescon-image.jpgrather thancon.jpg. A name that only starts with one, such asconsole-on-desk, is left alone.Not in this PR: names already stored in existing databases are not re-sanitised, and
ImportJsonstill aborts on a bad entry instead of skipping it per row. The triage comment lists both as separate follow-ups.Tests
ScanTests: the issue's example; every reserved character plus a tab and\u0001; four device names; and a name that only starts with a device name.🤖 Generated with Claude Code
https://claude.ai/code/session_01NwJrDAUtukhDgLo9pAfR3t
Generated by Claude Code