[PR #1801] scripts: harden meta_to_xml.ps1 null head, limit guard and atomic XML write #1814

Open
opened 2026-11-26 21:19:03 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1801
Author: @kirigayakazima
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/meta-to-xml-safety


📝 Commits (1)

  • 4ef1614 scripts: harden meta_to_xml.ps1 null head, limit guard and atomic XML write

📊 Changes

2 files changed (+74 additions, -3 deletions)

View changed files

📝 scripts/meta_to_xml.ps1 (+20 -3)
📝 tests/test_meta_to_xml_paths.py (+54 -0)

📄 Description

Claimed in the coordination issue as: META-TO-XML-NULL-HEAD-CASE-AND-LIMIT-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162168340)

What and why

  • Guard scripts/meta_to_xml.ps1 against bink2 or malformed index.json entries whose head is null/absent ($_.head -is [string]) instead of throwing InvokeMethodOnNull on .StartsWith(...).
  • Compare 5053494e / 52424630 hex prefixes case-insensitively (OrdinalIgnoreCase) in both filtering and $kind classification.
  • Reject negative -Limit values upfront (throw "-Limit must be 0 or greater.") instead of writing an empty failures.txt and exiting 0.
  • Stage XML outputs to a unique .tmp file beside the destination and publish via Move-Item -LiteralPath ... -Force with finally cleanup.
  • Add synthetic Windows PowerShell 5.1 regression tests in tests/test_meta_to_xml_paths.py.

Tested

  • python -I tests/test_meta_to_xml_paths.py -v (live Windows PowerShell 5.1) -> Ran 3 tests in 4.548s, OK (verified in a detached upstream/main worktree that both new tests fail before the fix: FAILED (failures=2)).
  • python -I tests/test_ci_registration.py -> Ran 16 tests in 4.507s, OK.
  • python -I tests/test_text_write_line_endings.py -> Ran 3 tests in 12.931s, OK.
  • python -I scripts/check_no_game_data.py scripts/meta_to_xml.ps1 tests/test_meta_to_xml_paths.py -> exit 0.
  • python -I -m compileall -q tests/test_meta_to_xml_paths.py and git diff --check -> clean.

GPUs tested: n/a (Windows PowerShell 5.1 + stdlib Python tests on Windows 11 x64)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1801 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/meta-to-xml-safety` --- ### 📝 Commits (1) - [`4ef1614`](https://github.com/ubiquitarianism/leonida/commit/4ef161444645f4cef691b0a274a1e635ac73234e) scripts: harden meta_to_xml.ps1 null head, limit guard and atomic XML write ### 📊 Changes **2 files changed** (+74 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `scripts/meta_to_xml.ps1` (+20 -3) 📝 `tests/test_meta_to_xml_paths.py` (+54 -0) </details> ### 📄 Description Claimed in the coordination issue as: META-TO-XML-NULL-HEAD-CASE-AND-LIMIT-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162168340) ### What and why - Guard `scripts/meta_to_xml.ps1` against `bink2` or malformed `index.json` entries whose `head` is null/absent (`$_.head -is [string]`) instead of throwing `InvokeMethodOnNull` on `.StartsWith(...)`. - Compare `5053494e` / `52424630` hex prefixes case-insensitively (`OrdinalIgnoreCase`) in both filtering and `$kind` classification. - Reject negative `-Limit` values upfront (`throw "-Limit must be 0 or greater."`) instead of writing an empty `failures.txt` and exiting `0`. - Stage XML outputs to a unique `.tmp` file beside the destination and publish via `Move-Item -LiteralPath ... -Force` with `finally` cleanup. - Add synthetic Windows PowerShell 5.1 regression tests in `tests/test_meta_to_xml_paths.py`. ### Tested - `python -I tests/test_meta_to_xml_paths.py -v` (live Windows PowerShell 5.1) -> `Ran 3 tests in 4.548s`, `OK` (verified in a detached `upstream/main` worktree that both new tests fail before the fix: `FAILED (failures=2)`). - `python -I tests/test_ci_registration.py` -> `Ran 16 tests in 4.507s`, `OK`. - `python -I tests/test_text_write_line_endings.py` -> `Ran 3 tests in 12.931s`, `OK`. - `python -I scripts/check_no_game_data.py scripts/meta_to_xml.ps1 tests/test_meta_to_xml_paths.py` -> exit `0`. - `python -I -m compileall -q tests/test_meta_to_xml_paths.py` and `git diff --check` -> clean. GPUs tested: n/a (Windows PowerShell 5.1 + stdlib Python tests on Windows 11 x64) AI-assisted: yes ### Checklist - [x] Based on current main and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1814
No description provided.