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 41a965c

Browse filesBrowse files
committed
[Mime] Leverage PHP 8's detection of CSV files.
1 parent 1e15aa6 commit 41a965c
Copy full SHA for 41a965c

File tree

Expand file treeCollapse file tree

3 files changed

+19
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+19
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/MimeTypes.php
+2-1Lines changed: 2 additions & 1 deletion
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'],
@@ -1817,7 +1818,7 @@ public function guessMimeType(string $path): ?string
18171818
'csp' => ['application/vnd.commonspace'],
18181819
'css' => ['text/css'],
18191820
'cst' => ['application/x-director'],
1820-
'csv' => ['text/csv', 'text/x-comma-separated-values', 'text/x-csv'],
1821+
'csv' => ['text/csv', 'text/x-comma-separated-values', 'text/x-csv', 'application/csv'],
18211822
'csvs' => ['text/csv-schema'],
18221823
'cu' => ['application/cu-seeme'],
18231824
'cue' => ['application/x-cue'],
+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.