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:
@@ -129,9 +129,9 @@ def heroic_parser(parent_widget, action):
|
||||
values["name"] = game["title"]
|
||||
values["developer"] = game["developer"]
|
||||
values["executable"] = (
|
||||
f"start heroic://launch/{app_name}"
|
||||
["start", f"heroic://launch/{app_name}"]
|
||||
if os.name == "nt"
|
||||
else f"xdg-open heroic://launch/{app_name}"
|
||||
else ["xdg-open", f"heroic://launch/{app_name}"]
|
||||
)
|
||||
values["hidden"] = False
|
||||
values["source"] = "heroic_epic"
|
||||
@@ -195,9 +195,9 @@ def heroic_parser(parent_widget, action):
|
||||
break
|
||||
|
||||
values["executable"] = (
|
||||
f"start heroic://launch/{app_name}"
|
||||
["start", f"heroic://launch/{app_name}"]
|
||||
if os.name == "nt"
|
||||
else f"xdg-open heroic://launch/{app_name}"
|
||||
else ["xdg-open", f"heroic://launch/{app_name}"]
|
||||
)
|
||||
values["hidden"] = False
|
||||
values["source"] = "heroic_gog"
|
||||
@@ -230,9 +230,9 @@ def heroic_parser(parent_widget, action):
|
||||
|
||||
values["name"] = item["title"]
|
||||
values["executable"] = (
|
||||
f"start heroic://launch/{app_name}"
|
||||
["start", f"heroic://launch/{app_name}"]
|
||||
if os.name == "nt"
|
||||
else f"xdg-open heroic://launch/{app_name}"
|
||||
else ["xdg-open", f"heroic://launch/{app_name}"]
|
||||
)
|
||||
values["hidden"] = False
|
||||
values["source"] = "heroic_sideload"
|
||||
|
||||
Reference in New Issue
Block a user