Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML File detected as plain/text #24

Open
zerlas opened this issue Aug 6, 2018 · 6 comments
Open

XML File detected as plain/text #24

zerlas opened this issue Aug 6, 2018 · 6 comments

Comments

@zerlas
Copy link

zerlas commented Aug 6, 2018

Calling GetFileType(this byte[] bytes) returns "plain/text" instead of "application/xml".

@clarkis117
Copy link
Collaborator

@zerlas Thank you for filing an issue but could you provide a better description, steps to reproduce, and sample data?

@zerlas
Copy link
Author

zerlas commented Aug 7, 2018

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"

@clarkis117
Copy link
Collaborator

@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?

@zerlas
Copy link
Author

zerlas commented Aug 7, 2018

i'm already on the last beta version : 0.0.6 beta4

@sandrock
Copy link

sandrock commented Aug 7, 2018

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-

@sandrock
Copy link

This has been fixed. The issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants