[PR #518] [MERGED] MODS-PARSE-HEX-PREFIX: reject bare 0x/0X prefix in parse_model_id #565

Closed
opened 2026-11-26 20:18:18 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/518
Author: @xroneyaa
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism

Base: main ← Head: fix/mods-parse-empty-hex-prefix


📝 Commits (1)

  • d6ca1fd mods: reject bare 0x/0X prefix in parse_model_id

📊 Changes

2 files changed (+7 additions, -2 deletions)

View changed files

📝 runtime/src/mods.h (+2 -2)
📝 runtime/test/mods_test.cpp (+5 -0)

📄 Description

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).

🔄 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/518 **Author:** [@xroneyaa](https://github.com/xroneyaa) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@ubiquitarianism](https://github.com/ubiquitarianism) **Base:** `main` ← **Head:** `fix/mods-parse-empty-hex-prefix` --- ### 📝 Commits (1) - [`d6ca1fd`](https://github.com/ubiquitarianism/leonida/commit/d6ca1fdaea7458f9a854f657fb58092336b61277) mods: reject bare 0x/0X prefix in parse_model_id ### 📊 Changes **2 files changed** (+7 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/mods.h` (+2 -2) 📝 `runtime/test/mods_test.cpp` (+5 -0) </details> ### 📄 Description 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:18 +01:00
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#565
No description provided.