-
Notifications
You must be signed in to change notification settings - Fork 166
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
PPT detected as 'application/x-ole-storage' #388
Comments
I see the same with an .xls file. Seems to be a common issue also in other mime detection libraries like ruby |
@eqinox76 I'm looking into how file --mime 2.ppt does detection in order to make it work in go. |
Sadly i cannot share the file. When i remove proprietary information and save it the resulting file is correctly recognised as "application/vnd.ms-excel". file in version 5.41 shows the correct mime type as well
I tried to debug this issue a bit more and see in
I hope this information helps a bit. |
@eqinox76 I have a suspicion that your problem happens because the excel signature is at the end of the file. mimetype.SetLimit(0) // Default limit is 3072. Setting the limit to 0 will make mimetype use whole file.
mtype, err := mimetype.DetectFile("your_file.xls") More details are in the FAQ |
Thanks for the tip. Sadly this file seems to work somehow different. i can not figure out which rule in the
Let me know if you have another idea what information i could share without sharing the whole file. |
@MrSwed your file is not detected because the signature is at the end of the file. Use @eqinox76 Your case seems more complicated. package main
import (
"encoding/binary"
"encoding/hex"
"fmt"
"os"
)
func main() {
d, err := os.ReadFile("1.xls")
if err != nil {
panic(err)
}
fmt.Println(getOleClsid(d))
}
func getOleClsid(in []byte) (int, string) {
sectorLength := 512
if in[26] == 0x04 && in[27] == 0x00 {
sectorLength = 4096
}
// SecID of first sector of the directory stream.
firstSecID := int(binary.LittleEndian.Uint32(in[48:52]))
// Expected offset of CLSID for root storage object.
clsidOffset := sectorLength*(1+firstSecID) + 80
return clsidOffset, hex.EncodeToString(in[clsidOffset : clsidOffset+16])
} |
Glad to do so! The output is
Some more information that might be handy:
|
Is this issue fixed now? I have the same issue and additional issues Checking ppt extension (file: test.ppt) Additional issues (file: test.doc) Version : github.com/gabriel-vasile/mimetype v1.4.5 |
The file for which the detection is inaccurate
2.zip
Expected MIME type
application/vnd.ms-powerpoint
Returned MIME type
application/x-ole-storage
Version of the library you are using
v1.4.1
Output of
go version
go version go1.16.15 linux/amd64
Additional context
https://www.htmlstrip.com/mime-file-type-checker and console command
file --mime-type 2.ppt
give correct resultsThe text was updated successfully, but these errors were encountered: