Skip to content

Commit

Permalink
Ignore invalid UTF-8 in config.vdf
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Matoking committed Jul 31, 2024
1 parent 6b95d6d commit d6dec65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- `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.

### Fixed
- Fix Protontricks crash when `config.vdf` contains invalid UTF-8 characters

## [1.11.1] - 2024-02-20
### Fixed
- Fix Protontricks crash when custom Proton has an invalid or empty `compatibilitytool.vdf` manifest
Expand Down
5 changes: 4 additions & 1 deletion src/protontricks/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,10 @@ def _get_tool_app(compat_tool_name, steam_apps, steam_play_manifest):
# Multiple configuration values might be found. In such case, select the
# one with the highest priority.
config_vdf_path = steam_path / "config" / "config.vdf"
content = config_vdf_path.read_text()
# config.vdf might contain invalid UTF-8 characters in the
# `SDL_GamepadBind` field. We don't use that in any way, so we can deal
# with the invalid characters by just ignoring them.
content = config_vdf_path.read_text(errors="replace")

vdf_data = lower_dict(vdf.loads(content))

Expand Down

0 comments on commit d6dec65

Please sign in to comment.