Skip to content

Commit

Permalink
umu_proton: handle exception when processing file
Browse files Browse the repository at this point in the history
- We don't control this file and as far as umu-launcher is concerned it's untrusted input so we should handle the error. In the future, other ways to determine the latest build should be explored
  • Loading branch information
R1kaB3rN committed Dec 13, 2024
1 parent 5eb0968 commit 5bf3d7a
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions umu/umu_proton.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,19 +388,26 @@ def _get_latest(
and compat_version.is_dir()
and compat_version.joinpath("compatibilitytool.vdf").is_file()
):
with umu_compat.joinpath(version, "compatibilitytool.vdf").open(
encoding="utf-8"
) as file:
# We're up to date if the internal tool is the GH asset name
# without the suffix. Note: This will break if Valve ever
# pivots to the VDF binary format
for line in file:
if proton not in line:
continue
log.info("%s is up to date", version)
os.environ["PROTONPATH"] = str(umu_compat.joinpath(proton))
env["PROTONPATH"] = os.environ["PROTONPATH"]
return env
vdf: Path = umu_compat.joinpath(version, "compatibilitytool.vdf")
try:
with vdf.open(encoding="utf-8") as file:
# We're up to date if the internal tool is the GH asset name
# without the suffix
for line in file:
if proton not in line:
continue
log.info("%s is up to date", version)
os.environ["PROTONPATH"] = str(umu_compat.joinpath(proton))
env["PROTONPATH"] = os.environ["PROTONPATH"]
return env
except UnicodeDecodeError:
# Case when the VDF file is the binary format/has non-utf-8 chars
# Return and fallback to Steam's compatibilitytools.d
log.warning(
"Failed opening file '%s', unable to determine latest build",
vdf,
)
return None

# Return if the latest Proton is already installed
if steam_compat.joinpath(proton).is_dir():
Expand Down

0 comments on commit 5bf3d7a

Please sign in to comment.