Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f727277

Browse files
committed
[Mime] remove some extensions by mime type
1 parent 50c18e5 commit f727277

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/Symfony/Component/Mime/MimeTypes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function guessMimeType(string $path): ?string
255255
'application/n-triples' => ['nt'],
256256
'application/nappdf' => ['pdf'],
257257
'application/node' => ['cjs'],
258-
'application/octet-stream' => ['bin', 'dms', 'lrf', 'mar', 'so', 'dist', 'distz', 'pkg', 'bpk', 'dump', 'elc', 'deploy', 'exe', 'dll', 'deb', 'dmg', 'iso', 'img', 'msi', 'msp', 'msm', 'buffer'],
258+
'application/octet-stream' => ['bin', 'dms', 'lrf', 'mar', 'so', 'dist', 'distz', 'pkg', 'bpk', 'dump', 'elc', 'deploy', 'exe', 'dll', 'deb', 'dmg', 'iso', 'img', 'msp', 'msm', 'buffer'],
259259
'application/oda' => ['oda'],
260260
'application/oebps-package+xml' => ['opf'],
261261
'application/ogg' => ['ogx'],
@@ -2568,7 +2568,7 @@ public function guessMimeType(string $path): ?string
25682568
'msf' => ['application/vnd.epson.msf'],
25692569
'msg' => ['application/vnd.ms-outlook'],
25702570
'msh' => ['model/mesh'],
2571-
'msi' => ['application/octet-stream', 'application/x-msdownload', 'application/x-msi'],
2571+
'msi' => ['application/x-msdownload', 'application/x-msi'],
25722572
'msl' => ['application/vnd.mobius.msl'],
25732573
'msm' => ['application/octet-stream'],
25742574
'msod' => ['image/x-msod'],

src/Symfony/Component/Mime/Resources/bin/update_mime_types.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,24 @@
6464
$map = array_replace_recursive($current, $new);
6565
ksort($map);
6666

67-
// force some extension to be in the first position of the map
68-
$forceExtensionMap = [
67+
// remove some extensions from the map
68+
$removeExtensionByMimeType = [
69+
'application/octet-stream' => 'msi',
70+
];
71+
foreach ($removeExtensionByMimeType as $mimeType => $extension) {
72+
if (false !== ($idx = array_search($extension, $map[$mimeType]))) {
73+
unset($map[$mimeType][$idx]);
74+
}
75+
}
76+
77+
// force an extension to be in the first position on the map
78+
$forceExtensionInFirstPositionByMimeType = [
6979
'application/vnd.apple.keynote' => 'key',
7080
'audio/mpeg' => 'mp3',
7181
'text/markdown' => 'md',
7282
'text/x-markdown' => 'md',
7383
];
74-
foreach ($forceExtensionMap as $mimeType => $extension) {
84+
foreach ($forceExtensionInFirstPositionByMimeType as $mimeType => $extension) {
7585
$map[$mimeType] = array_unique(array_merge([$extension], $map[$mimeType]));
7686
}
7787

0 commit comments

Comments
 (0)