fix: Properly quote paths in commands [needs additional cross-platform testing]#149
Merged
Conversation
patchzyy
approved these changes
May 5, 2025
patchzyy
added a commit
that referenced
this pull request
May 5, 2025
commit 29653f5 Merge: eac36c0 a361ef3 Author: patchzyy <64382339+patchzyy@users.noreply.github.com> Date: Mon May 5 16:57:13 2025 +0200 Merge pull request #149 from matellush/fix/command-injections fix: Properly quote paths in commands [needs additional cross-platform testing] commit a361ef3 Author: patchzyy <64382339+patchzyy@users.noreply.github.com> Date: Mon May 5 16:52:30 2025 +0200 formatting commit 0f35d8f Author: patchzyy <64382339+patchzyy@users.noreply.github.com> Date: Mon May 5 16:44:59 2025 +0200 Formatting commit ca7bd24 Author: matellush <202132988+matellush@users.noreply.github.com> Date: Mon May 5 16:15:24 2025 +0200 fix: Specify Unix LF for Linux-specific source file commit b932d49 Author: matellush <202132988+matellush@users.noreply.github.com> Date: Sun May 4 11:08:44 2025 +0200 fix: Properly quote paths in commands
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.
Purpose of this PR:
Mitigate potential unintentional command injections in commands using paths dependent on the environment or user input. We now use the right quoting/escaping methods depending on the context (e.g. the OS).
How to Test:
Ensure that the auto updater still works correctly on Windows. Also, test the Linux auto updater (comment out the line for that) with the WheelWizard executable in a directory with some special characters (spaces, quotes, ...) – the script should be able to run without issues. In addition, it should be ensured that spaces or quotes in paths do not affect the program's ability to launch the game or open the folders (e.g. in
explorer.exe). These changes have been tested on a fixed Flatpak build of Wheel Wizard: https://github.com/matellush/io.github.TeamWheelWizard.WheelWizard/commit/0073dfc89251bf24705528dfb2cbc9304808c9de. The wrappers were missing quotes around the$@, which will be fixed in the nextflathubbuild. Using the changes of this PR in combination with the Flatpak wrapper fixes, Wheel Wizard has been confirmed to be able to correctly pass the arguments even with spaces, double or single quotes in the paths.What Has Been Changed:
The way paths are quoted and escaped. These changes also affect the Windows and Linux auto updaters. Two helper methods have been added for Windows PowerShell path quoting (
SingleQuotePath) without interpolations andQuotePathfor the usual double-quoting. Linux and macOS are now using single quotes in their commands to ensure no unintended shell expansions would occur.Related Issue Link:
#148
Discussion Points:
It would be a good idea to re-enable the Linux auto updater after these changes, as it should quote the paths correctly now in the script.
Checklist before merging