HLE: a '>' in a quoted manifest attribute does not end its tag #359

Merged
Dufftwt merged 1 commit from upstream-pr/359 into main 2026-11-25 00:10:35 +00:00
Dufftwt commented 2026-11-24 02:34:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dufftwt on 2026-11-24T02:34:36Z.


What's wrong

runtime::elements reads MicrosoftGame.config to get the title id (Game/TitleId) and the storage quota (Game/PersistentLocalStorage/SizeMB). It ends every tag at the tag's first >.

XML allows > unescaped inside an attribute value (XML 1.0 §3.1: AttValue ::= '"' ([^<&"] | Reference)* '"'). So a manifest with, say:

<ShellVisuals DefaultDisplayName="A > B" … />
<TitleId>639AA8DD</TitleId>

has its ShellVisuals tag cut short at A . The /> that closes the element is never seen, the element stays open, and every element after it is read as its child (Game/ShellVisuals/TitleId). Title::from_manifest then finds no title id and no quota.

run.rs goes on with title id 00000000 and a 0-byte storage quota: the title's storage, saves and temporary files go under data/00000000/, with no warning. Only the title 00000000 line in the console hints at it.

What the fix does

A new helper, tag_end, ends a tag at the first > that is outside a "…" or '…' attribute value. Comments and CDATA sections are handled as before.

How it behaves after the fix

Manifests whose attribute values contain > give their real title id and storage quota. Manifests without one are read exactly as before.

Tests

  • The new test a_quoted_angle_bracket_does_not_end_its_tag has a > in a double-quoted and in a single-quoted attribute value before TitleId. It expects (0x639AA8DD, 64 MiB).
  • The existing manifest test still passes.

I ran cargo test --workspace on GitHub's windows-latest with Rust 1.98.1 from rust-toolchain.toml:

  • This PR: everything passes. victory-hle has 87 passed, the other crates have 0 failed.
  • The new test alone on main: it fails with title id and quota (0, 0) instead of (0x639AA8DD, 64 MiB).
  • I ran with --test-threads=1. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (#181, #244).

Not tested: a real title's manifest with such a value.

Related: #112 and #337 also edit this file, a few lines further down. Neither conflicts with this change.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6573326130 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/359). Originally posted by [Dufftwt](https://github.com/Dufftwt) on 2026-11-24T02:34:36Z. --- ## What's wrong `runtime::elements` reads `MicrosoftGame.config` to get the title id (`Game/TitleId`) and the storage quota (`Game/PersistentLocalStorage/SizeMB`). It ends every tag at the tag's first `>`. XML allows `>` **unescaped inside an attribute value** (XML 1.0 §3.1: `AttValue ::= '"' ([^<&"] | Reference)* '"'`). So a manifest with, say: ```xml <ShellVisuals DefaultDisplayName="A > B" … /> <TitleId>639AA8DD</TitleId> ``` has its `ShellVisuals` tag cut short at `A `. The `/>` that closes the element is never seen, the element stays open, and every element after it is read as its child (`Game/ShellVisuals/TitleId`). `Title::from_manifest` then finds no title id and no quota. `run.rs` goes on with title id `00000000` and a 0-byte storage quota: the title's storage, saves and temporary files go under `data/00000000/`, with no warning. Only the `title 00000000` line in the console hints at it. ## What the fix does A new helper, `tag_end`, ends a tag at the first `>` that is **outside** a `"…"` or `'…'` attribute value. Comments and CDATA sections are handled as before. ## How it behaves after the fix Manifests whose attribute values contain `>` give their real title id and storage quota. Manifests without one are read exactly as before. ## Tests - The new test `a_quoted_angle_bracket_does_not_end_its_tag` has a `>` in a double-quoted and in a single-quoted attribute value before `TitleId`. It expects `(0x639AA8DD, 64 MiB)`. - The existing manifest test still passes. I ran `cargo test --workspace` on GitHub's `windows-latest` with Rust 1.98.1 from `rust-toolchain.toml`: - **This PR:** everything passes. `victory-hle` has 87 passed, the other crates have 0 failed. - **The new test alone on `main`:** it fails with title id and quota `(0, 0)` instead of `(0x639AA8DD, 64 MiB)`. - I ran with `--test-threads=1`. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (#181, #244). **Not tested:** a real title's manifest with such a value. Related: #112 and #337 also edit this file, a few lines further down. Neither conflicts with this change.
jeremygold02 commented 2026-11-24 06:55:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:27:11Z.


Tested PR #359 at head d549b6397e3f40e77f9da670344aa15f12b26abb (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at d549b6397e3f40e77f9da670344aa15f12b26abb.

  • cargo test --locked -p victory-hle a_quoted_angle_bracket_does_not_end_its_tag — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 86 filtered out; finished in 0.00s ); cases: runtime::tests::a_quoted_angle_bracket_does_not_end_its_tag.

Behavior covered: Checks quoted angle brackets do not terminate manifest tags and title/store/quota fields still parse.
Code: crates/victory-hle/src/runtime.rs

<!-- greyfinch-sync:Marvisak/VIctory:comment:7122032590 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/359#issuecomment-7122032590). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:27:11Z. --- Tested PR #359 at head `d549b6397e3f40e77f9da670344aa15f12b26abb` (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at `d549b6397e3f40e77f9da670344aa15f12b26abb`. - `cargo test --locked -p victory-hle a_quoted_angle_bracket_does_not_end_its_tag` — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 86 filtered out; finished in 0.00s ); cases: runtime::tests::a_quoted_angle_bracket_does_not_end_its_tag. Behavior covered: Checks quoted angle brackets do not terminate manifest tags and title/store/quota fields still parse. Code: [crates/victory-hle/src/runtime.rs](https://github.com/Marvisak/VIctory/blob/d549b6397e3f40e77f9da670344aa15f12b26abb/crates/victory-hle/src/runtime.rs)
mercuryVM commented 2026-11-24 09:05:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:03:16Z.

Review: APPROVED


Tested d549b63 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed).

  • XML 1.0 allows a raw > in an attribute value, so the old find('>') was wrong for any manifest with one. tag_end tracks " and ' and only ends the tag on an unquoted >.
  • I checked the cases that could regress:
    • Comments and CDATA are still split off before tag_end (the <!-- and <![CDATA[ arms), so an apostrophe in a comment can't start a "quote".
    • <?xml version="1.0"?> and similar declarations have balanced quotes.
    • Element text isn't scanned by tag_end at all.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6035624992 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/359#pullrequestreview-6035624992). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T08:03:16Z. **Review:** APPROVED --- Tested d549b63 on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (265 passed, 0 failed). - XML 1.0 allows a raw `>` in an attribute value, so the old `find('>')` was wrong for any manifest with one. `tag_end` tracks `"` and `'` and only ends the tag on an unquoted `>`. - I checked the cases that could regress: - Comments and CDATA are still split off before `tag_end` (the `<!--` and `<![CDATA[` arms), so an apostrophe in a comment can't start a "quote". - `<?xml version="1.0"?>` and similar declarations have balanced quotes. - Element text isn't scanned by `tag_end` at all. No issues found. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 01:03:29 +00:00
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
Marvisak/VIctory!359
No description provided.