fix(relinker): accept a UTF-8 BOM in patch metadata #25897

Merged
mcarkade merged 1 commit from upstream-pr/25897 into main 2026-11-27 18:32:21 +00:00
mcarkade commented 2026-11-22 20:29:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mcarkade on 2026-11-22T20:29:47Z.


What

Accept the optional UTF-8 byte order mark at the start of native patch metadata. Previously the parser rejected the file before it could read the opening JSON object.

Tested

Windows 11 with MinGW GCC 15.2. A metadata-only document with zero patch entries and a UTF-8 BOM failed against the original native parser and loaded after the change. The production relinker_game_patch CTest target passed. Conventions passed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5443070305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25897). Originally posted by [mcarkade](https://github.com/mcarkade) on 2026-11-22T20:29:47Z. --- ### What Accept the optional UTF-8 byte order mark at the start of native patch metadata. Previously the parser rejected the file before it could read the opening JSON object. ### Tested Windows 11 with MinGW GCC 15.2. A metadata-only document with zero patch entries and a UTF-8 BOM failed against the original native parser and loaded after the change. The production `relinker_game_patch` CTest target passed. Conventions passed. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-22 20:37:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-22T20:37:34Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 3d667086a1:

  • Conventions: tools/check_conventions.py passed.
  • Build: relinker_game_patch_tests built cleanly.
  • CTest (relinker_game_patch):
    1/1 Test #6383: relinker_game_patch ..............   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/relinker/relinker/src/patching/GamePatch.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #6383: relinker_game_patch ..............***Failed    0.01 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified that stripping the leading UTF-8 BOM (\xef\xbb\xbf) in ParsePatchFile before ValidateUtf8 and parsing does not introduce out-of-bounds reads or undefined behavior using std::string_view::starts_with and std::string_view::remove_prefix.
    • Confirmed that ValidateUtf8 correctly validates the remaining input without the BOM and line numbering remains consistent across comments, keys, and values.
    • Checked UTF-8 BOM representation: "\xef\xbb\xbf" accurately represents the 3-byte sequence EF BB BF (U+FEFF).
    • Verified that passing std::string_view by value in ParsePatchFile is idiomatic and clean across Linux LP64 and Windows LLP64 targets.
    • Checked AGENTS.md compliance: conventions check passed, no illegal comments introduced, no special casing, and the test in GamePatchTests.cpp directly exercises the BOM stripping and metadata parsing.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6014413043 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25897#pullrequestreview-6014413043). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-22T20:37:34Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `3d667086a1`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `relinker_game_patch_tests` built cleanly. - **CTest** (`relinker_game_patch`): ``` 1/1 Test #6383: relinker_game_patch .............. Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/relinker/relinker/src/patching/GamePatch.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #6383: relinker_game_patch ..............***Failed 0.01 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified that stripping the leading UTF-8 BOM (\xef\xbb\xbf) in ParsePatchFile before ValidateUtf8 and parsing does not introduce out-of-bounds reads or undefined behavior using std::string_view::starts_with and std::string_view::remove_prefix. - Confirmed that ValidateUtf8 correctly validates the remaining input without the BOM and line numbering remains consistent across comments, keys, and values. - Checked UTF-8 BOM representation: "\xef\xbb\xbf" accurately represents the 3-byte sequence EF BB BF (U+FEFF). - Verified that passing std::string_view by value in ParsePatchFile is idiomatic and clean across Linux LP64 and Windows LLP64 targets. - Checked AGENTS.md compliance: conventions check passed, no illegal comments introduced, no special casing, and the test in GamePatchTests.cpp directly exercises the BOM stripping and metadata parsing. Looks Good To Me
MarcZX10 commented 2026-11-22 22:52:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T22:52:00Z.

Review: APPROVED


Reviewed — looks good

Nothing in the reviewed change blocks merging, and the implementation matches the stated goal of accepting a UTF-8 BOM at the start of patch metadata.

What I ran

Reviewed head 3d667086a1d8894f26725472f921844041d3598e. I did not run commands or tests; the Windows 11 CTest and conventions results are author-reported.

Results

Check Result Note
Code review passed Both changed files read
Tests not run Results are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

Tests were not run in this review. Read core/relinker/relinker/src/patching/GamePatch.cpp and core/relinker/relinker/tests/GamePatchTests.cpp; files.json was not available in the prepared review folder, so excluded files and the reviewed-file list could not be independently confirmed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6014956395 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25897#pullrequestreview-6014956395). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T22:52:00Z. **Review:** APPROVED --- # Reviewed — looks good Nothing in the reviewed change blocks merging, and the implementation matches the stated goal of accepting a UTF-8 BOM at the start of patch metadata. ## What I ran Reviewed head `3d667086a1d8894f26725472f921844041d3598e`. I did not run commands or tests; the Windows 11 CTest and conventions results are author-reported. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Both changed files read | | Tests | not run | Results are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Tests were not run in this review. Read `core/relinker/relinker/src/patching/GamePatch.cpp` and `core/relinker/relinker/tests/GamePatchTests.cpp`; `files.json` was not available in the prepared review folder, so excluded files and the reviewed-file list could not be independently confirmed. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!25897
No description provided.