-
-
Notifications
You must be signed in to change notification settings - Fork 247
Harden phpcs utilities: escape filenames instead of only spaces #1532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: wintercms/winter
Length of output: 5889
🏁 Script executed:
Repository: wintercms/winter
Length of output: 4777
🌐 Web query:
Git diff --name-only -z pathname quoting documentation core.quotePath C-style quoted filenames💡 Result:
In Git, commands that output pathnames—such as git diff --name-only—default to quoting "unusual" characters in filenames [1][2]. This behavior is controlled by the configuration variable core.quotePath [2][3]. When core.quotePath is enabled (the default), Git inspects pathnames for characters deemed "unusual," which include control characters (such as TAB, LF, and backslash) and non-ASCII bytes (values greater than 0x80) [2][3][4]. If any such character is detected, the entire pathname is enclosed in double quotes, and the special characters are escaped using C-style backslash notation (e.g., \t, \n, \, or octal sequences like \302\265) [2][3]. Notably, a simple space is not considered an "unusual" character and does not trigger this quoting behavior [2][4]. If core.quotePath is set to false, Git stops quoting non-ASCII bytes (values > 0x80) and outputs them verbatim [2][3]. However, double quotes, backslashes, and control characters will still be escaped regardless of this setting [2][3]. To bypass this quoting mechanism entirely and receive filenames verbatim regardless of their content, you can use the -z option [1][5][2]. When -z is used with commands like git diff --name-only, pathnames are output exactly as they are, and each entry is terminated by a NUL byte rather than a newline [1][5][2]. Configuration: You can disable the automatic quoting of non-ASCII characters by running: git config --global core.quotePath false Top results: [1] https://git-scm.com/docs/git-diff [2] https://git-scm.com/docs/git-config/2.20.0 [3] https://linux.die.net/man/1/git-config [4] https://public-inbox.org/git/201001011844.23571.agruen@suse.de/T/
Citations:
Decode Git pathnames before shell escaping in both utilities.
git diff --name-onlyandgit show --name-onlycan emit C-quoted pathnames.escapeshellarg()then passes the encoded text to PHPCS, so PHPCS may skip the changed file. Use-z, split$fileListon"\0", and escape each raw pathname in both utilities.📍 Affects 2 files
.github/workflows/utilities/phpcs-pr#L28-L30(this comment).github/workflows/utilities/phpcs-push#L28-L30🤖 Prompt for AI Agents