Fixed bad extension computing wigh SVG file without xml header line.

This commit is contained in:
Christian P. MOMON 2021-03-01 02:02:33 +01:00
parent 6b227a9d12
commit abf0aebedf

View file

@ -116,6 +116,13 @@ public class StatoolInfosUtils
String mimeTypeLabel = tika.detect(file);
MimeType mimeType = MimeTypes.getDefaultMimeTypes().forName(mimeTypeLabel);
result = mimeType.getExtension();
// Because Tika failed to recognize SVG file without xml header
// line.
if (result.equals(".txt") && (StringUtils.startsWithIgnoreCase(FileUtils.readFileToString(file, "UTF8"), "<svg")))
{
result = ".svg";
}
}
catch (IOException | MimeTypeException exception)
{