Skip to content

Commit 61b1479

Browse files
committed
Ignore invalid UTF-8 in config.vdf
Ignore invalid UTF-8 characters when parsing `config.vdf`. These sometimes appear under `SDL_GamepadBind`, which might be related to the library. In any case, we do not use any of that data so we can safely ignore this error. Fixes #317
1 parent f7b1fa3 commit 61b1479

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1111
### Changed
1212
- `protontricks -c` and `protontricks-launch` now use the current working directory instead of the game's installation directory. `--cwd-app` can be used to restore old behavior. Scripts can also `$STEAM_APP_PATH` environment variable to determine the game's installation directory; this has been supported (albeit undocumented) since 1.8.0.
1313

14+
### Fixed
15+
- Fix Protontricks crash when `config.vdf` contains invalid Unicode characters
16+
1417
## [1.11.1] - 2024-02-20
1518
### Fixed
1619
- Fix Protontricks crash when custom Proton has an invalid or empty `compatibilitytool.vdf` manifest

src/protontricks/steam.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,10 @@ def _get_tool_app(compat_tool_name, steam_apps, steam_play_manifest):
657657
# Multiple configuration values might be found. In such case, select the
658658
# one with the highest priority.
659659
config_vdf_path = steam_path / "config" / "config.vdf"
660-
content = config_vdf_path.read_text()
660+
# config.vdf might contain invalid UTF-8 characters in the
661+
# `SDL_GamepadBind` field. We don't use that in any way, so we can deal
662+
# with the invalid characters by just ignoring them.
663+
content = config_vdf_path.read_text(errors="replace")
661664

662665
vdf_data = lower_dict(vdf.loads(content))
663666

0 commit comments

Comments
 (0)