Skip to content

Commit e184963

Browse files
committed
Added detection for vsd files
1 parent 1911a01 commit e184963

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/SoftCreatR/MimeDetector/MimeDetector.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,18 @@ public function getFileType(): array
786786
}
787787

788788
if ($this->checkForBytes([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) {
789+
// MS Visio
790+
if ($this->checkForBytes([
791+
0x56, 0x00, 0x69, 0x00, 0x73,
792+
0x00, 0x69, 0x00, 0x6F, 0x00,
793+
0x44, 0x00, 0x6F, 0x00, 0x63
794+
], 1664)) {
795+
return [
796+
'ext' => 'vsd',
797+
'mime' => 'application/vnd.visio'
798+
];
799+
}
800+
789801
return [
790802
'ext' => 'msi',
791803
'mime' => 'application/x-msi'
@@ -937,7 +949,7 @@ public function getFileType(): array
937949
'mime' => 'audio/basic'
938950
];
939951
}
940-
952+
941953
// unfortunately, these formats don't have a proper mime type, but they are worth detecting
942954
if ($this->checkForBytes([0x67, 0x33, 0x64, 0x72, 0x65, 0x6D])) {
943955
return [

tests/SoftCreatR/MimeDetector/MimeDetectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ public function provideTestFiles(): array
394394
$files[$file->getBasename()] = [
395395
'file' => $file->getPathname(),
396396
'hash' => $this->getInstance()->getHash($file->getPathname()),
397-
'ext' => $file->getExtension()
397+
'ext' => strtolower($file->getExtension())
398398
];
399399
}
400400
}
@@ -420,7 +420,7 @@ public function provideSingleTestFile(): array
420420
$fileInfo = [
421421
'file' => $file->getPathname(),
422422
'hash' => $this->getInstance()->getHash($file->getPathname()),
423-
'ext' => $file->getExtension()
423+
'ext' => strtolower($file->getExtension())
424424
];
425425
}
426426
}
Submodule fixtures updated 1 file

0 commit comments

Comments
 (0)