Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitb21025b

Browse files
security #cve-2019-18888 [HttpFoundation] fix guessing mime-types of files with leading dash (nicolas-grekas)
This PR was merged into the 3.4 branch.
2 parents0102134 +6be5cc7 commitb21025b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

‎src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FileBinaryMimeTypeGuesser implements MimeTypeGuesserInterface
3131
*
3232
* @param string $cmd The command to run to get the mime type of a file
3333
*/
34-
publicfunction__construct($cmd ='file -b --mime %s 2>/dev/null')
34+
publicfunction__construct($cmd ='file -b --mime--%s 2>/dev/null')
3535
{
3636
$this->cmd =$cmd;
3737
}
@@ -80,7 +80,7 @@ public function guess($path)
8080
ob_start();
8181

8282
// need to use --mime instead of -i. see #6641
83-
passthru(sprintf($this->cmd,escapeshellarg($path)),$return);
83+
passthru(sprintf($this->cmd,escapeshellarg((0 ===strpos($path,'-') ?'./' :'').$path)),$return);
8484
if ($return >0) {
8585
ob_end_clean();
8686

Binary file not shown.

‎src/Symfony/Component/HttpFoundation/Tests/File/MimeType/MimeTypeTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@
2020
*/
2121
class MimeTypeTestextends TestCase
2222
{
23-
protected$path;
23+
publicfunctiontestGuessWithLeadingDash()
24+
{
25+
$cwd =getcwd();
26+
chdir(__DIR__.'/../Fixtures');
27+
try {
28+
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess('-test'));
29+
}finally {
30+
chdir($cwd);
31+
}
32+
}
2433

2534
publicfunctiontestGuessImageWithoutExtension()
2635
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp