diff --git a/core.js b/core.js index 407b0e8d..7a859031 100644 --- a/core.js +++ b/core.js @@ -1210,6 +1210,16 @@ 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..348e55dc 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 610a6f24..5a1147da 100644 --- a/test.js +++ b/test.js @@ -209,6 +209,8 @@ const names = { xml: [ 'fixture', 'fixture-utf8-bom', // UTF-8 with BOM + 'fixture-utf16-be-bom', // UTF-16 little endian encoded XML, with BOM + 'fixture-utf16-le-bom', // UTF-16 big endian encoded XML, with BOM ], };