File tree 1 file changed +27
-1
lines changed
src/Symfony/Component/HttpFoundation/File/MimeType
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,33 @@ public function __construct($cmd = 'file -b --mime %s 2>/dev/null')
43
43
*/
44
44
public static function isSupported ()
45
45
{
46
- return '\\' !== DIRECTORY_SEPARATOR && function_exists ('passthru ' ) && function_exists ('escapeshellarg ' );
46
+ static $ supported ;
47
+
48
+ if (isset ($ supported )) {
49
+ return $ supported ;
50
+ }
51
+
52
+ if ('\\' === DIRECTORY_SEPARATOR || !function_exists ('passthru ' ) || !function_exists ('escapeshellarg ' )) {
53
+ return $ supported = false ;
54
+ }
55
+
56
+ ob_start ();
57
+
58
+ passthru ('command -v file ' , $ return );
59
+ if ($ return > 0 ) {
60
+ ob_end_clean ();
61
+
62
+ return $ supported = false ;
63
+ }
64
+
65
+ $ binPath = trim (ob_get_clean ());
66
+
67
+ if (!preg_match ('#^(?:/[^\0/])+# ' , $ binPath )) {
68
+ // it's not a bin path, but an error message
69
+ return $ supported = false ;
70
+ }
71
+
72
+ return $ supported = true ;
47
73
}
48
74
49
75
/**
You can’t perform that action at this time.
0 commit comments