Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2a9476

Browse filesBrowse files
authored
[MimeType] Duplicated MimeType due to PHP Bug
## Issue: Currently there is a PHP bug https://bugs.php.net/bug.php?id=77784 that is causing several MimeTypes to be given as duplicated: ``` application/vnd.openxmlformats-officedocument.spreadsheetml.sheetapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet ``` Instead of: ``` application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ``` This Patch will fix the Issues by checking if a returned MimeType is duplicated and return appropriate MimeType. This patch should be reverted if the PHP Bug is ever fixed.
1 parent bf2fb93 commit e2a9476
Copy full SHA for e2a9476

File tree

1 file changed

+8
-1
lines changed
Filter options

1 file changed

+8
-1
lines changed

‎src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/FileinfoMimeTypeGuesser.php
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ public function guessMimeType(string $path): ?string
5858
return null;
5959
}
6060

61-
return $finfo->file($path);
61+
$mimeType = $finfo->file($path);
62+
63+
if($mimeType) {
64+
$mimeStart = substr($mimeType, 0, strlen($mimeType)/2);
65+
$mimeType = substr($mimeType, strlen($mimeType)/2) === $mimeStart ? $mimeStart : $mimeType;
66+
}
67+
68+
return $mimeType;
6269
}
6370
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.