mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:45:53 +01:00
[PR #1522] ped_catalogues: fix filter/BOM/traversal/depth-cap bugs and atomic JSON I/O (PED-CATALOGUES-VALIDATION-AND-IO-HARDENING) #1552
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1552
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1522
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/ped-catalogues-hardening📝 Commits (1)
8ab99b8ped_catalogues: fix filter/BOM/traversal/depth-cap bugs and atomic JSON I/O (PED-CATALOGUES-VALIDATION-AND-IO-HARDENING)📊 Changes
2 files changed (+310 additions, -18 deletions)
View changed files
📝
tests/test_ped_catalogues.py(+232 -0)📝
tools/ped_catalogues.py(+78 -18)📄 Description
Summary
Fixes several correctness bugs and hardens file/CLI I/O in
tools/ped_catalogues.py:--names-file/ blank--name(_cmd_resolve): passing a comment-only/blank--names-fileor blank--namepreviously passeddrawable_names=Nonetoresolve_preset_bindings, disabling filtering and emitting every binding instead of 0 matches._cmd_resolve,iter_catalogues_in_dir): opens--names-fileand carvedindex.jsonwithencoding="utf-8-sig"(so a leading UTF-8 BOM does not corrupt the first hashed drawable name or breakindex.jsonparsing) and catchesUnicodeDecodeErrorcleanly.index.json(iter_catalogues_in_dir): verifies both primary and continuation row paths stay inside the carved folder via_is_under_dir.MAX_PARENT_DEPTHwarning &max_depthvalidation (parse_catalogue_blocks,resolve_ancestor_tags,resolve_effective_tags,resolve_preset_bindings): checks whetherparent.parent_idis non-zero before emitting the depth-cap warning so clean exact-depth chains do not warn falsely, and rejects negative orboolmax_depth.inspect --max-inflate(iter_catalogues_in_file,iter_catalogues_in_dir,iter_catalogues_in_rpf,_cmd_inspect): validates integer bounds onstart,limit, andmax_inflate(rejecting non-positive orboolvalues), adds--max-inflatetoinspect, enforces the file-size cap before reading, and reports zlib inflate/cap failures explicitly._write_json,_cmd_census,_cmd_inspect,_cmd_resolve): stages JSON output via sibling temp file withnewline="\n",allow_nan=False,file_mode.published_mode, andreplace_retry.replace, and catches write(OSError, ValueError)with exit code 2 instead of an uncaught traceback.Coordination
PED-CATALOGUES-VALIDATION-AND-IO-HARDENING(https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7151759976)Testing
python3 -I tests/test_ped_catalogues.py -v— 16/16 OK (including 6 new regression tests inPedCataloguesHardeningTests)python3 -I tests/test_text_write_line_endings.py— 3/3 OKpython3 -I scripts/check_no_game_data.py tools/ped_catalogues.py tests/test_ped_catalogues.py— cleanpython3 -m compileall -q tools/ped_catalogues.py tests/test_ped_catalogues.py— cleanmain:tools/ped_catalogues.py: 6/6 tests inPedCataloguesHardeningTestsfail (FAILED (failures=12)).Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.