mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:45:53 +01:00
[PR #1557] gamedata_reader: fix --root filter, sanitize --out filenames, and write JSON atomically (GAMEDATA-READER-FILTER-AND-OUT-IO) #1580
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#1580
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/1557
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/gamedata-reader-filter-and-out-io📝 Commits (1)
b6721dcgamedata_reader: fix --root filter, sanitize --out filenames, and write JSON atomically📊 Changes
2 files changed (+124 additions, -18 deletions)
View changed files
📝
tests/test_gamedata_reader.py(+53 -0)📝
tools/gamedata_reader.py(+71 -18)📄 Description
What
Fix
--rootfiltering, unsafe export filenames, and--outI/O handling intools/gamedata_reader.py:--outexport (_safe_stem,run):ET.iterparseexpands XML namespaces to Clark notation ({http://example.com/ns}Root), sof"{tag}_{name}.json"contained/and:and crashed withFileNotFoundError/OSError.[<>:"/\\|?*\x00-\x1f]) with_while leaving ordinary ASCII tag/file stems unchanged.--rootmissed valid documents without a matchingroot_hint(run):hint != root_filterdropped documents whoseroot_hintwas empty (e.g. a self-closing root after<!DOCTYPE ...>) or lacked the namespace prefix of a Clark-notation--rootfilter, and never verified the parsedtagagainstroot_filter.hintis non-empty and matches neitherroot_filternor its local name (root_filter.endswith("}" + hint)), and verifytag == root_filterafter parsing.--out, atomic LF-terminated writes, and accurate write error diagnostics (main,run):--outpaths withERROR: --out path must not be empty(exit2) instead of silently ignoring""or creating a whitespace-named folder.newline="\n", trailing"\n",file_mode.published_mode,replace_retry.replace), and report writeOSErrors asERROR: cannot write ...instead ofERROR: cannot read ....Claimed in the coordination issue as
GAMEDATA-READER-FILTER-AND-OUT-IO— verified 0 open PRs and 0 prior claims; unable to post a comment on#14because GitHub disabled commenting once#14reached its 2,500-comment cap (and no successor"Coordinating who works on what"issue is open yet).Testing
python3 -I -W error tests/test_gamedata_reader.py -v: 25/25 OK (including 3 new regression tests).python3 -I tests/test_text_write_line_endings.py: 3/3 OK.python3 -I scripts/check_no_game_data.py tools/gamedata_reader.py tests/test_gamedata_reader.py: clean.python3 -m compileall -q tools/gamedata_reader.py tests/test_gamedata_reader.py: clean.Mutation check against unpatched
main:tools/gamedata_reader.py: all 3 new tests fail onmain(FAILED (failures=3, errors=2)).AI-assisted: yes
GPUs tested: none (CPU-only XML reader tests on macOS; no GPU or game files needed)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.