Skip to content

Commit 6310084

Browse files
committed
bug #36716 [Mime] handle passing custom mime types as string (mcneely)
This PR was merged into the 4.4 branch. Discussion ---------- [Mime] handle passing custom mime types as string | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #36715 | License | MIT | Doc PR | none Fix's issue where custom mimetypes were failing Commits ------- f3005ec Fix for #36715
2 parents 99d5818 + f3005ec commit 6310084

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Symfony/Component/Mime/MimeTypes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(array $map = [])
5151
$this->extensions[$mimeType] = $extensions;
5252

5353
foreach ($extensions as $extension) {
54-
$this->mimeTypes[$extension] = $mimeType;
54+
$this->mimeTypes[$extension][] = $mimeType;
5555
}
5656
}
5757
$this->registerGuesser(new FileBinaryMimeTypeGuesser());

src/Symfony/Component/Mime/Tests/MimeTypesTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,15 @@ public function testGetMimeTypes()
6262
$this->assertContains('image/svg', $mt->getMimeTypes('svg'));
6363
$this->assertSame([], $mt->getMimeTypes('symfony'));
6464
}
65+
66+
public function testCustomMimeTypes()
67+
{
68+
$mt = new MimeTypes([
69+
'text/bar' => ['foo'],
70+
'text/baz' => ['foo', 'moof'],
71+
]);
72+
$this->assertContains('text/bar', $mt->getMimeTypes('foo'));
73+
$this->assertContains('text/baz', $mt->getMimeTypes('foo'));
74+
$this->assertSame(['foo', 'moof'], $mt->getExtensions('text/baz'));
75+
}
6576
}

0 commit comments

Comments
 (0)