LibXML: Prevent auto-detection of UTF-32 encoding by libxml2

This commit is contained in:
Tim Ledbetter
2026-01-08 00:39:09 +00:00
committed by Jelle Raaijmakers
parent 0d22b6cee5
commit a48aa62b7a
Notes: github-actions[bot] 2026-01-08 09:07:40 +00:00
3 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
test(() => {
const parser = new DOMParser();
const doc1 = parser.parseFromString("<root/>", "application/xml");
println(`Normal XML: characterSet=${doc1.characterSet}, element=${doc1.documentElement.localName}`);
const doc2 = parser.parseFromString('<?xml version="1.0" encoding="UTF-32"?><root/>', "application/xml");
println(`UTF-32 declared: characterSet=${doc2.characterSet}, element=${doc2.documentElement.localName}`);
const doc3 = parser.parseFromString('<?xml version="1.0" encoding="UTF-32BE"?><root/>', "application/xml");
println(`UTF-32BE declared: characterSet=${doc3.characterSet}, element=${doc3.documentElement.localName}`);
const doc4 = parser.parseFromString('<?xml version="1.0" encoding="UTF-32LE"?><root/>', "application/xml");
println(`UTF-32LE declared: characterSet=${doc4.characterSet}, element=${doc4.documentElement.localName}`);
});
</script>