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

The MicrosoftGame.config reader ended a tag at its first '>', but XML
allows '>' unescaped inside an attribute value. A value with one
(DefaultDisplayName="A > B") cut the tag short: its '/>' was never
seen, so the element stayed open and every element after it was read
as its child. Game/TitleId and the storage quota were then not found,
and the title ran as id 00000000 with no storage quota, its saves and
temporary files in that folder, without a warning.

A tag now ends at the first '>' outside quotes.

(cherry picked from commit d549b6397e3f40e77f9da670344aa15f12b26abb)
This commit is contained in:
Duff authored and local committed 2026-11-25 01:02:58 -06:00
1 parent f4a7ae21ad
commit 803ada0162
1 file changed
+25 -1
+25 -1
View File
@@ -140,7 +140,7 @@ fn elements(text: &str) -> Vec<(String, String)> {
} else if rest.starts_with("<![CDATA[") {
rest.find("]]>").map(|e| e + 3)
} else {
rest.find('>').map(|e| e + 1)
tag_end(rest)
};
let Some(end) = end else { break };
let tag = &rest[1..end - 1];
@@ -173,6 +173,21 @@ fn elements(text: &str) -> Vec<(String, String)> {
out
}
/// Where the tag that starts `text` ends, past its `>`; a `>` in a quoted
/// attribute value is part of the value (XML allows it there unescaped).
fn tag_end(text: &str) -> Option<usize> {
let mut quote = None;
for (at, c) in text.char_indices() {
match (quote, c) {
(None, '"' | '\'') => quote = Some(c),
(Some(open), _) if c == open => quote = None,
(None, '>') => return Some(at + 1),
_ => {}
}
}
None
}
static TITLE: Mutex<Option<Title>> = Mutex::new(None);
pub fn set_title(title: Title) {
@@ -223,6 +238,15 @@ pub fn use_console_timers() {
mod tests {
use super::*;
#[test]
fn a_quoted_angle_bracket_does_not_end_its_tag() {
let text = "<Game><ShellVisuals DefaultDisplayName=\"A > B\" Description='x>y'/>\
<TitleId>639AA8DD</TitleId>\
<PersistentLocalStorage><SizeMB>64</SizeMB></PersistentLocalStorage></Game>";
let t = Title::from_manifest(text);
assert_eq!((t.id, t.storage_bytes), (0x639A_A8DD, 64 << 20));
}
#[test]
fn reads_title_id_store_id_and_storage_quota() {
let text = "\u{feff}<?xml version=\"1.0\"?>\n<Game configVersion=\"1\">\