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

FileMagicNumber.getMagicNumbe判断错误;doc文件错误被认为是xls文件 #3408

Closed
jdzgd opened this issue Nov 28, 2023 · 1 comment
Closed
Labels

Comments

@jdzgd
Copy link

jdzgd commented Nov 28, 2023

版本情况

JDK版本: openjdk_20
hutool版本: 5.8.23(请确保最新尝试是否还有问题)

问题描述(包括截图)

doc文件错误被认为是xls文件

  1. 复现代码
            byte[] bytes = StreamUtils.copyToByteArray(fileData.getInputStream());
            String mimeType = FileMagicNumber.getMagicNumber(bytes).getMimeType();
  1. 堆栈信息

  2. 测试涉及到的文件(注意脱密)

image image

由于文件涉密暂不能提供,但已确认是doc文件且被word打开

@looly
Copy link
Member

looly commented Nov 28, 2023

如果文件经过WPS编辑,会导致magic number错误。

考虑扩展名辅助识别。

@looly looly closed this as completed Nov 28, 2023
@looly looly added the question label Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants