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

Merged
xroneyaa merged 1 commit from upstream-pr/518 into main 2026-11-24 16:11:19 +00:00
xroneyaa commented 2026-11-24 06:51:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by xroneyaa on 2026-11-24T06:51:11Z.


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).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5467529462 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/518). Originally posted by [xroneyaa](https://github.com/xroneyaa) on 2026-11-24T06:51:11Z. --- 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).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!518
No description provided.