Improved game executable launcher, and added argument validation

Now uses proper shell escaping and parsing for all executable arguments, for more robust game launching. All existing game JSON files with the old string values will automatically be converted to the new format on app launch. The executable parsing uses the "shlex" library, which guarantees accurate parsing.

We now also use direct process launching (without any intermediary shell) by default, but the old "shell"-based launch method still exists in the code via an alternative flag in `run_command.py` (if we ever need to restore it for some reason).

Furthermore, if the user attempts to manually write an improperly escaped argument into the game's details (such as missing closing quotation marks), the GUI will now alert the user that their executable argument is invalid, along with telling them the exact reason why it's invalid.
This commit is contained in:
Bananaman
2023-03-24 21:44:31 +01:00
parent eda22c7ea7
commit 703c65395c
6 changed files with 85 additions and 24 deletions

View File

@@ -64,9 +64,9 @@ def get_game(task, datatypes, current_time, parent_widget, appmanifest, steam_di
return
values["executable"] = (
f'start steam://rungameid/{values["appid"]}'
["start", f'steam://rungameid/{values["appid"]}']
if os.name == "nt"
else f'xdg-open steam://rungameid/{values["appid"]}'
else ["xdg-open", f'steam://rungameid/{values["appid"]}']
)
values["hidden"] = False
values["source"] = "steam"