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 0ee8af1

Browse filesBrowse files
committed
[Mime] Leverage PHP 8's detection of CSV files.
1 parent da65c57 commit 0ee8af1
Copy full SHA for 0ee8af1

File tree

Expand file treeCollapse file tree

3 files changed

+18
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+18
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/MimeTypes.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public function guessMimeType(string $path): ?string
166166
'application/cdmi-queue' => ['cdmiq'],
167167
'application/cdr' => ['cdr'],
168168
'application/coreldraw' => ['cdr'],
169+
'application/csv' => ['csv'],
169170
'application/cu-seeme' => ['cu'],
170171
'application/davmount+xml' => ['davmount'],
171172
'application/dbase' => ['dbf'],
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a,b,c
2+
d,e,f
3+
g,h,i

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/MimeTypesTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,18 @@ public function testCustomMimeTypes()
7373
$this->assertContains('text/baz', $mt->getMimeTypes('foo'));
7474
$this->assertSame(['foo', 'moof'], $mt->getExtensions('text/baz'));
7575
}
76+
77+
/**
78+
* PHP 8 detects .csv files as "application/csv" while PHP 7 returns "text/plain".
79+
*
80+
* @requires PHP 8
81+
*/
82+
public function testCsvExtension()
83+
{
84+
$mt = new MimeTypes();
85+
86+
$mime = $mt->guessMimeType(__DIR__.'/Fixtures/mimetypes/abc.csv');
87+
$this->assertSame('application/csv', $mime);
88+
$this->assertSame(['csv'], $mt->getExtensions($mime));
89+
}
7690
}

0 commit comments

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