Fix path parsing when trailing backslash precedes closing quote on Windows#189
Open
joffrey-b wants to merge 1 commit into
Open
Fix path parsing when trailing backslash precedes closing quote on Windows#189joffrey-b wants to merge 1 commit into
joffrey-b wants to merge 1 commit into
Conversation
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.
Summary
On Windows, passing a quoted path with a trailing backslash (e.g.
"C:\Music\My Album\") causes rsgain to report a misleading "does not exist" error, with a stray"visible at the end of the path in the error message. This affects both easy mode and custom mode.Closes #187
Root cause
Windows'
CommandLineToArgvWtreats\"as an escaped literal"rather than the closing delimiter of a quoted argument. As a result, a path like"C:\Music\My Album\"is parsed by the C runtime asC:\Music\My Album"— the trailing backslash is consumed as an escape character, and the quote becomes part of the string.This is a common friction point because PowerShell tab-completion for paths with spaces automatically appends a trailing
\, making this the default form users encounter.Fix
Before constructing a
std::filesystem::pathfrom a command-line path argument on Windows, strip a trailing"character if present.Changes
src/easymode.cpp— strip trailing"from the directory argument before passing toscan_easy()src/scan.cpp— strip trailing"from each file path argument before assigning to the filesystem pathTesting
Tested on Windows 11 with PowerShell. The following previously failing invocations now work correctly: