Skip to content

Commit 4026b8c

Browse files
committed
Handle differently-encoded XMLs as textfiles
1 parent 6d2e2d8 commit 4026b8c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

SabreTools.Serialization/Wrappers/WrapperFactory.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,14 @@ public static WrapperType GetFileType(byte[]? magic, string? extension)
703703
if (magic.StartsWith([0x3C, 0x3F, 0x78, 0x6D, 0x6C]))
704704
return WrapperType.Textfile;
705705

706+
// "<?xml" in UTF-16 encoding
707+
if (magic.StartsWith([0x3C, 0x00, 0x3F, 0x00, 0x78, 0x00, 0x6D, 0x00, 0x6C, 0x00]))
708+
return WrapperType.Textfile;
709+
710+
// "<?xml" in UTF-16 encoding with byte order marks
711+
if (magic.StartsWith([0xFF, 0xFE, 0x3C, 0x00, 0x3F, 0x00, 0x78, 0x00, 0x6D, 0x00, 0x6C, 0x00]))
712+
return WrapperType.Textfile;
713+
706714
// "Description in Zip"
707715
if (extension.Equals("diz", StringComparison.OrdinalIgnoreCase))
708716
return WrapperType.Textfile;

0 commit comments

Comments
 (0)