MODS-PARSE-HEX-PREFIX: reject bare 0x/0X prefix in parse_model_id #518

Manually merged
github merged 1 commit from gh-pr/518/head into gh-pr/518/base 2026-11-26 09:05:34 +00:00
Owner

@⁠xroneyaa on GitHub · 2026-11-24 06:51 UTC · original
xroneyaa:fix/mods-parse-empty-hex-prefix → main · +7 −2 · 2 files · 1 commits · merged 2026-11-24 16:11 UTC

Claimed in the coordination issue as: MODS-PARSE-HEX-PREFIX

What and why

In runtime/src/mods.h, leonida::mods::parse_model_id checks if (text.size() > 2 && text[0] == '0' && (text[1] == 'x' || text[1] == 'X')) before parsing hexadecimal digits. A bare "0x" or "0X" (text.size() == 2) skipped the hex branch, fell through to out = joaat(text), and returned true instead of refusing the malformed hex value as the comment specifies.

This accepts text.size() >= 2 for the "0x"/"0X" prefix check and rejects text.size() == 2 alongside text.size() > 10, leaving joaat() untouched. It also adds unit coverage in runtime/test/mods_test.cpp verifying "0x", "0X", and a "0x" archetype swap entry are refused without clobbering out.

Tested

  • Rebuilt mods_test with MSVC 19.50 / Ninja (0 warnings)
  • ctest --test-dir runtime/build --output-on-failure -R "^mods$" -> 1/1 Passed (0.01 s)
  • python -I scripts/check_no_game_data.py runtime/src/mods.h runtime/test/mods_test.cpp -> exit 0

GPUs tested: n/a (CPU-only unit test)

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 — no translator rule added).
**@⁠xroneyaa** on GitHub · 2026-11-24 06:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/518) `xroneyaa:fix/mods-parse-empty-hex-prefix` → `main` · +7 −2 · 2 files · 1 commits · merged 2026-11-24 16:11 UTC Claimed in the coordination issue as: MODS-PARSE-HEX-PREFIX ### What and why In `runtime/src/mods.h`, `leonida::mods::parse_model_id` checks `if (text.size() > 2 && text[0] == '0' && (text[1] == 'x' || text[1] == 'X'))` before parsing hexadecimal digits. A bare `"0x"` or `"0X"` (`text.size() == 2`) skipped the hex branch, fell through to `out = joaat(text)`, and returned `true` instead of refusing the malformed hex value as the comment specifies. This accepts `text.size() >= 2` for the `"0x"`/`"0X"` prefix check and rejects `text.size() == 2` alongside `text.size() > 10`, leaving `joaat()` untouched. It also adds unit coverage in `runtime/test/mods_test.cpp` verifying `"0x"`, `"0X"`, and a `"0x"` archetype swap entry are refused without clobbering `out`. ### Tested - Rebuilt `mods_test` with MSVC 19.50 / Ninja (0 warnings) - `ctest --test-dir runtime/build --output-on-failure -R "^mods$"` -> 1/1 Passed (`0.01 s`) - `python -I scripts/check_no_game_data.py runtime/src/mods.h runtime/test/mods_test.cpp` -> exit 0 GPUs tested: n/a (CPU-only unit test) 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 — no translator rule added).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:05:32 +00:00
github manually merged commit d6ca1fdaea into gh-pr/518/base 2026-11-26 09:05:34 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.