8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 514e5bb + 9e4b3ac commit cabe672Copy full SHA for cabe672
File/MimeType/FileBinaryMimeTypeGuesser.php
@@ -36,7 +36,7 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface
36
*
37
* @param string $cmd The command to run to get the mime type of a file
38
*/
39
- public function __construct(string $cmd = 'file -b --mime %s 2>/dev/null')
+ public function __construct(string $cmd = 'file -b --mime -- %s 2>/dev/null')
40
{
41
$this->cmd = $cmd;
42
}
@@ -85,7 +85,7 @@ public function guess($path)
85
ob_start();
86
87
// need to use --mime instead of -i. see #6641
88
- passthru(sprintf($this->cmd, escapeshellarg($path)), $return);
+ passthru(sprintf($this->cmd, escapeshellarg((0 === strpos($path, '-') ? './' : '').$path)), $return);
89
if ($return > 0) {
90
ob_end_clean();
91
Tests/File/Fixtures/-test
35 Bytes
Tests/File/MimeType/MimeTypeTest.php
@@ -21,6 +21,17 @@
21
22
class MimeTypeTest extends TestCase
23
24
+ public function testGuessWithLeadingDash()
25
+ {
26
+ $cwd = getcwd();
27
+ chdir(__DIR__.'/../Fixtures');
28
+ try {
29
+ $this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess('-test'));
30
+ } finally {
31
+ chdir($cwd);
32
+ }
33
34
+
35
public function testGuessImageWithoutExtension()
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));