Open zerlas opened 6 years ago
@zerlas Thank you for filing an issue but could you provide a better description, steps to reproduce, and sample data?
i'm sorry, when i'm trying to get the type of a XML file like this :
var path = Path.Combine(this.TestContext.DeploymentDirectory, "file.smmx"); // this file is a correct XML file
using (var file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var stream = new MemoryStream((int)file.Length))
{
file.CopyTo(stream);
var streamArray = stream.ToArray();
var type = streamArray.GetFileType();
type.ShouldNotBeNull();
type.Mime.ShouldEqual("application/xml"); // this line crash because type.Mime == "plain/text"
}
This line : type.Mime.ShouldEqual("application/xml");
Crash because it return the type "plain/text"
@zerlas Hmmm.... Given that XML files are plain text it may be matching on a Unicode byte order mark. Have you tried this file with the beta version of the library?
i'm already on the last beta version : 0.0.6 beta4
Here are the first bytes of a problematic XML file on my side. Using nuget 0.0.6-beta4.
efbb bf3c 3f78 6d6c 2076 6572 7369 6f6e ...<?xml version
3d22 312e 3022 2065 6e63 6f64 696e 673d ="1.0" encoding=
2255 5446 2d38 223f 3e0d 0a3c 2144 4f43 "UTF-8"?>..<!DOC
5459 5045 2073 696d 706c 656d 696e 642d TYPE simplemind-
This has been fixed. The issue can be closed.
Calling
GetFileType(this byte[] bytes)
returns "plain/text" instead of "application/xml".