diff --git a/core.js b/core.js index d3d6ab53..119047a5 100644 --- a/core.js +++ b/core.js @@ -1203,6 +1203,15 @@ async function _fromTokenizer(tokenizer) { }; } + if (check([0xFE, 0xFF, 0, 60, 0, 63, 0, 120, 0, 109, 0, 108]) // UTF-16-BOM-LE + || check([0xFF, 0xFE, 60, 0, 63, 0, 120, 0, 109, 0, 108, 0]) + ) { // UTF-16-BOM-LE + return { + ext: 'xml', + mime: 'application/xml', + }; + } + // -- Unsafe signatures -- if ( diff --git a/fixture/fixture-utf16-be-bom.xml b/fixture/fixture-utf16-be-bom.xml new file mode 100644 index 00000000..07070ed5 Binary files /dev/null and b/fixture/fixture-utf16-be-bom.xml differ diff --git a/fixture/fixture-utf16-le-bom.xml b/fixture/fixture-utf16-le-bom.xml new file mode 100644 index 00000000..cf1c066d Binary files /dev/null and b/fixture/fixture-utf16-le-bom.xml differ diff --git a/test.js b/test.js index b27bddd3..9d4dc2c3 100644 --- a/test.js +++ b/test.js @@ -206,6 +206,11 @@ const names = { webm: [ 'fixture-null', // EBML DocType with trailing null character ], + xml: [ + 'fixture', + 'fixture-utf16-be-bom', // UTF-16 little endian encoded XML, with BOM + 'fixture-utf16-le-bom', // UTF-16 big endian encoded XML, with BOM + ], }; // Define an entry here only if the file type has potential