Skip to content

lds_fuzz, valu_fuzz: handle UTF-8 BOM on index.json reads - #6131

Open
jaybeebabageyus wants to merge 1 commit into
ItsNotRexed:mainfrom
jaybeebabageyus:fuzz-index-utf8-bom
Open

jaybeebabageyus wants to merge 1 commit into
ItsNotRexed:mainfrom
jaybeebabageyus:fuzz-index-utf8-bom

Conversation

@jaybeebabageyus

Copy link
Copy Markdown
Contributor

Fixes UTF-8 BOM handling when reading index.json in tools/lds_fuzz.py and tools/valu_fuzz.py (sibling of #6017 / #5877, claimed in #5934).

Changes

  • tools/lds_fuzz.py: use encoding="utf-8-sig" when reading spirv/index.json in translate().
  • tools/valu_fuzz.py: use encoding="utf-8-sig" when reading spirv/index.json in translate().
  • tests/test_lds_fuzz_cli.py: add synthetic UTF-8 BOM index.json unit test (test_translate_reads_index_with_utf8_bom).
  • tests/test_valu_fuzz.py: add synthetic UTF-8 BOM index.json unit test (test_translate_reads_index_with_utf8_bom).

Testing

Tested on Windows CPU with Blender Python 3.11 (-I):

  • python -I -m compileall -q tools/lds_fuzz.py tools/valu_fuzz.py tests/test_valu_fuzz.py tests/test_lds_fuzz_cli.py (exit 0)
  • python -I tests/test_lds_fuzz_cli.py -v (9/9 passed)
  • python -I tests/test_lds_fuzz.py -v (36/36 passed)
  • python -I tests/test_ci_registration.py -v (14/14 passed)
  • python -I scripts/check_no_game_data.py (exit 0)
  • test_valu_fuzz.test_translate_reads_index_with_utf8_bom executed directly via unittest.mock shim (passed; pytest not installed in Blender Python 3.11)

AI-assisted; synthetic tests only, no copyrighted game files or GPU used.

@LAKSHYA-cmd-tech LAKSHYA-cmd-tech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review on Windows 11 x64, Python 3.12 (-I).

  • Red-first verification: On parent revision before the fix, a synthetic BOM-prefixed \spirv/index.json\ (\xef\xbb\xbf{...}) raised \json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)\ in both \ ools/lds_fuzz.py:translate()\ and \ ools/valu_fuzz.py:translate(). On head, both correctly decode and return the expected index dictionary.
  • \python -I -m compileall -q tools/lds_fuzz.py tools/valu_fuzz.py tests/test_valu_fuzz.py tests/test_lds_fuzz_cli.py\ (exit 0)
  • \python -I tests/test_lds_fuzz_cli.py -v\ (9/9 passed, including \ est_translate_reads_index_with_utf8_bom)
  • \python -I tests/test_lds_fuzz.py -v\ (36/36 passed)
  • \python -I tests/test_ci_registration.py\ (14/14 passed)
  • \python -I tests/test_text_write_line_endings.py\ (3/3 passed)
  • \python -I scripts/check_no_game_data.py\ (exit 0)
  • \git diff --check\ clean (0).

LGTM. AI-assisted; synthetic tests only, zero game data or GPU used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants