Skip to content

fix: Properly quote paths in commands [needs additional cross-platform testing]#149

Merged
patchzyy merged 4 commits into
TeamWheelWizard:devfrom
matellush:fix/command-injections
May 5, 2025
Merged

fix: Properly quote paths in commands [needs additional cross-platform testing]#149
patchzyy merged 4 commits into
TeamWheelWizard:devfrom
matellush:fix/command-injections

Conversation

@matellush

Copy link
Copy Markdown
Collaborator

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 next flathub build. 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 and QuotePath for 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

  • You have created relevant tests

@patchzyy patchzyy merged commit 29653f5 into TeamWheelWizard:dev May 5, 2025
1 check passed
@matellush matellush deleted the fix/command-injections branch May 5, 2025 15:15
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
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.

2 participants