Ticket #45615: 45615.4.diff
| File 45615.4.diff, 6.6 KB (added by , 7 years ago) |
|---|
-
src/wp-includes/functions.php
diff --git src/wp-includes/functions.php src/wp-includes/functions.php index fdaa2e13e1..de0a05b5bb 100644
function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { 2569 2569 * This means that common mismatches are forgiven: application/vnd.apple.numbers is often misidentified as application/zip, 2570 2570 * and some media files are commonly named with the wrong extension (.mov instead of .mp4) 2571 2571 */ 2572 2573 2572 if ( substr( $real_mime, 0, strcspn( $real_mime, '/' ) ) !== substr( $type, 0, strcspn( $type, '/' ) ) ) { 2574 2573 $type = $ext = false; 2575 2574 } 2575 } elseif ( 'text/plain' === $real_mime ) { 2576 // A few common file types are occasionally detected as text/plain; allow those. 2577 if ( ! in_array( $type, array( 'text/plain', 'text/csv', 'text/tsv', 'text/vtt' ) ) ) { 2578 $type = $ext = false; 2579 } 2576 2580 } else { 2577 2581 if ( $type !== $real_mime ) { 2578 2582 /* … … function wp_get_mime_types() { 2696 2700 'css' => 'text/css', 2697 2701 'htm|html' => 'text/html', 2698 2702 'vtt' => 'text/vtt', 2699 'dfxp' => 'application/ttaf+xml',2700 2703 // Audio formats. 2701 2704 'mp3|m4a|m4b' => 'audio/mpeg', 2702 2705 'aac' => 'audio/aac', -
new file tests/phpunit/data/uploads/test.csv
diff --git tests/phpunit/data/uploads/test.csv tests/phpunit/data/uploads/test.csv new file mode 100644 index 0000000000..4231c785ca
- + 1 "country","country group","name (en)","name (fr)","name (de)","latitude","longitude" 2 "at","eu","Austria","Autriche","Österreich","47.6965545","13.34598005" 3 "be","eu","Belgium","Belgique","Belgien","50.501045","4.47667405" 4 "bg","eu","Bulgaria","Bulgarie","Bulgarien","42.72567375","25.4823218" 5 "country","country group","name (en)","name (fr)","name (de)","latitude","longitude" 6 "at","eu","Austria","Autriche","Österreich","47.6965545","13.34598005" 7 "be","eu","Belgium","Belgique","Belgien","50.501045","4.47667405" 8 "bg","eu","Bulgaria","Bulgarie","Bulgarien","42.72567375","25.4823218" 9 No newline at end of file -
new file tests/phpunit/data/uploads/test.tsv
diff --git tests/phpunit/data/uploads/test.tsv tests/phpunit/data/uploads/test.tsv new file mode 100644 index 0000000000..86fcad13e3
- + 1 sample tsv file 1 2 some text here 2 3 yup it's text 3 4 sample tsv file 1 5 some text here 2 6 yup it's text 3 7 No newline at end of file -
new file tests/phpunit/data/uploads/test.vtt
diff --git tests/phpunit/data/uploads/test.vtt tests/phpunit/data/uploads/test.vtt new file mode 100644 index 0000000000..a734662600
- + 1 WEBVTT 2 3 00:11.000 --> 00:13.000 4 <v Roger Bingham>We are in New York City 5 6 00:13.000 --> 00:16.000 7 <v Roger Bingham>We’re actually at the Lucern Hotel, just down the street 8 9 00:16.000 --> 00:18.000 10 <v Roger Bingham>from the American Museum of Natural History 11 12 00:18.000 --> 00:20.000 13 <v Roger Bingham>And with me is Neil deGrasse Tyson 14 15 00:20.000 --> 00:22.000 16 <v Roger Bingham>Astrophysicist, Director of the Hayden Planetarium 17 18 00:22.000 --> 00:24.000 19 <v Roger Bingham>at the AMNH. 20 21 00:24.000 --> 00:26.000 22 <v Roger Bingham>Thank you for walking down here. 23 24 00:27.000 --> 00:30.000 25 <v Roger Bingham>And I want to do a follow-up on the last conversation we did. 26 27 00:30.000 --> 00:31.500 align:right size:50% 28 <v Roger Bingham>When we e-mailed— 29 30 00:30.500 --> 00:32.500 align:left size:50% 31 <v Neil deGrasse Tyson>Didn’t we talk about enough in that conversation? 32 33 00:32.000 --> 00:35.500 align:right size:50% 34 <v Roger Bingham>No! No no no no; 'cos 'cos obviously 'cos 35 36 00:32.500 --> 00:33.500 align:left size:50% 37 <v Neil deGrasse Tyson><i>Laughs</i> 38 39 00:35.500 --> 00:38.000 40 <v Roger Bingham>You know I’m so excited my glasses are falling off here. 41 WEBVTT 42 43 00:11.000 --> 00:13.000 44 <v Roger Bingham>We are in New York City 45 46 00:13.000 --> 00:16.000 47 <v Roger Bingham>We’re actually at the Lucern Hotel, just down the street 48 49 00:16.000 --> 00:18.000 50 <v Roger Bingham>from the American Museum of Natural History 51 52 00:18.000 --> 00:20.000 53 <v Roger Bingham>And with me is Neil deGrasse Tyson 54 55 00:20.000 --> 00:22.000 56 <v Roger Bingham>Astrophysicist, Director of the Hayden Planetarium 57 58 00:22.000 --> 00:24.000 59 <v Roger Bingham>at the AMNH. 60 61 00:24.000 --> 00:26.000 62 <v Roger Bingham>Thank you for walking down here. 63 64 00:27.000 --> 00:30.000 65 <v Roger Bingham>And I want to do a follow-up on the last conversation we did. 66 67 00:30.000 --> 00:31.500 align:right size:50% 68 <v Roger Bingham>When we e-mailed— 69 70 00:30.500 --> 00:32.500 align:left size:50% 71 <v Neil deGrasse Tyson>Didn’t we talk about enough in that conversation? 72 73 00:32.000 --> 00:35.500 align:right size:50% 74 <v Roger Bingham>No! No no no no; 'cos 'cos obviously 'cos 75 76 00:32.500 --> 00:33.500 align:left size:50% 77 <v Neil deGrasse Tyson><i>Laughs</i> 78 79 00:35.500 --> 00:38.000 80 <v Roger Bingham>You know I’m so excited my glasses are falling off here. 81 No newline at end of file -
tests/phpunit/tests/functions.php
diff --git tests/phpunit/tests/functions.php tests/phpunit/tests/functions.php index f76c342c2f..22e6442b9f 100644
class Tests_Functions extends WP_UnitTestCase { 1230 1230 } 1231 1231 1232 1232 /** 1233 * Data pro fider for test_wp_get_image_mime();1233 * Data provider for test_wp_get_image_mime(); 1234 1234 */ 1235 1235 public function _wp_get_image_mime() { 1236 1236 $data = array( … … class Tests_Functions extends WP_UnitTestCase { 1336 1336 'proper_filename' => false, 1337 1337 ), 1338 1338 ), 1339 // Non-image file not allowed even if it's named like one. 1340 array( 1341 DIR_TESTDATA . '/export/crazy-cdata.xml', 1342 'crazy-cdata.jpg', 1343 array( 1344 'ext' => false, 1345 'type' => false, 1346 'proper_filename' => false, 1347 ), 1348 ), 1349 // Non-image file not allowed if it's named like something else. 1350 array( 1351 DIR_TESTDATA . '/export/crazy-cdata.xml', 1352 'crazy-cdata.doc', 1353 array( 1354 'ext' => false, 1355 'type' => false, 1356 'proper_filename' => false, 1357 ), 1358 ), 1359 // Assorted text/* sample files 1360 array( 1361 DIR_TESTDATA . '/uploads/test.vtt', 1362 'test.vtt', 1363 array( 1364 'ext' => 'vtt', 1365 'type' => 'text/vtt', 1366 'proper_filename' => false, 1367 ), 1368 ), 1369 array( 1370 DIR_TESTDATA . '/uploads/test.csv', 1371 'test.csv', 1372 array( 1373 'ext' => 'csv', 1374 'type' => 'text/csv', 1375 'proper_filename' => false, 1376 ), 1377 ), 1339 1378 ); 1340 1379 1341 1380 // Test a few additional file types on single sites.