mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1526] gamedata_maps: support UTF-8 BOM index.json, validate row fields, and write JSON atomically (GAMEDATA-MAPS-INDEX-AND-ATOMIC-IO) #1557
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#1557
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/1526
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/gamedata-maps-hardening📝 Commits (1)
2a384e1gamedata_maps: support UTF-8 BOM index.json, validate row fields, and write JSON atomically (GAMEDATA-MAPS-INDEX-AND-ATOMIC-IO)📊 Changes
2 files changed (+126 additions, -18 deletions)
View changed files
📝
tests/test_gamedata_maps.py(+57 -0)📝
tools/gamedata_maps.py(+69 -18)📄 Description
Summary
Hardens carve index loading, payload parsing, and JSON report writing in
tools/gamedata_maps.py:_read_index_rows,_read_row,_row_nonneg_int,read_payloads): opensindex.jsonwithencoding="utf-8-sig", validates thatoffis a non-negative non-boolinteger (preserving the existingrow N needs an 'off'diagnostic when missing), validateshead(string orNone) andsize/stored(non-negative non-boolint orNone), and stops continuation joins on empty missing chunks.parse_pamh): checks[offset + start, offset + start + count)againsthalfonce per non-empty row and copies max/min slices directly._write_json,main): stages--jsonoutput via a sibling temp file withnewline="\n", trailing LF,allow_nan=False,file_mode.published_mode, andreplace_retry.replace, preserving pre-existing files on error.Coordination
GAMEDATA-MAPS-INDEX-AND-ATOMIC-IO(https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7151890540)Testing
python3 -I tests/test_gamedata_maps.py -v— 28/28 OK (including 3 new regression tests)python3 -I tests/test_gamedata_maps_bad_index.py -v— 8/8 OKpython3 -I tests/test_missing_input_exit_codes.py— 2/2 OKpython3 -I tests/test_psin_psch.py— 4/4 OKpython3 -I tests/test_text_write_line_endings.py— 3/3 OKpython3 -I scripts/check_no_game_data.py tools/gamedata_maps.py tests/test_gamedata_maps.py— cleanpython3 -m compileall -q tools/gamedata_maps.py tests/test_gamedata_maps.py— cleanmain:tools/gamedata_maps.py: 3/3 new tests fail (FAILED (failures=5, errors=2)).Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.