WordPress.org

Make WordPress Core

Ticket #45615: 45615.4.diff

File 45615.4.diff, 6.6 KB (added by joemcgill, 4 months 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 ) { 
    25692569                         * This means that common mismatches are forgiven: application/vnd.apple.numbers is often misidentified as application/zip,
    25702570                         * and some media files are commonly named with the wrong extension (.mov instead of .mp4)
    25712571                         */
    2572 
    25732572                        if ( substr( $real_mime, 0, strcspn( $real_mime, '/' ) ) !== substr( $type, 0, strcspn( $type, '/' ) ) ) {
    25742573                                $type = $ext = false;
    25752574                        }
     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                        }
    25762580                } else {
    25772581                        if ( $type !== $real_mime ) {
    25782582                                /*
    function wp_get_mime_types() { 
    26962700                        'css'                          => 'text/css',
    26972701                        'htm|html'                     => 'text/html',
    26982702                        'vtt'                          => 'text/vtt',
    2699                         'dfxp'                         => 'application/ttaf+xml',
    27002703                        // Audio formats.
    27012704                        'mp3|m4a|m4b'                  => 'audio/mpeg',
    27022705                        '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
    - +  
     1sample  tsv     file    1
     2some    text    here    2
     3yup     it's    text    3
     4sample  tsv     file    1
     5some    text    here    2
     6yup     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
    - +  
     1WEBVTT
     2
     300:11.000 --> 00:13.000
     4<v Roger Bingham>We are in New York City
     5
     600:13.000 --> 00:16.000
     7<v Roger Bingham>We’re actually at the Lucern Hotel, just down the street
     8
     900:16.000 --> 00:18.000
     10<v Roger Bingham>from the American Museum of Natural History
     11
     1200:18.000 --> 00:20.000
     13<v Roger Bingham>And with me is Neil deGrasse Tyson
     14
     1500:20.000 --> 00:22.000
     16<v Roger Bingham>Astrophysicist, Director of the Hayden Planetarium
     17
     1800:22.000 --> 00:24.000
     19<v Roger Bingham>at the AMNH.
     20
     2100:24.000 --> 00:26.000
     22<v Roger Bingham>Thank you for walking down here.
     23
     2400:27.000 --> 00:30.000
     25<v Roger Bingham>And I want to do a follow-up on the last conversation we did.
     26
     2700:30.000 --> 00:31.500 align:right size:50%
     28<v Roger Bingham>When we e-mailed—
     29
     3000:30.500 --> 00:32.500 align:left size:50%
     31<v Neil deGrasse Tyson>Didn’t we talk about enough in that conversation?
     32
     3300:32.000 --> 00:35.500 align:right size:50%
     34<v Roger Bingham>No! No no no no; 'cos 'cos obviously 'cos
     35
     3600:32.500 --> 00:33.500 align:left size:50%
     37<v Neil deGrasse Tyson><i>Laughs</i>
     38
     3900:35.500 --> 00:38.000
     40<v Roger Bingham>You know I’m so excited my glasses are falling off here.
     41WEBVTT
     42
     4300:11.000 --> 00:13.000
     44<v Roger Bingham>We are in New York City
     45
     4600:13.000 --> 00:16.000
     47<v Roger Bingham>We’re actually at the Lucern Hotel, just down the street
     48
     4900:16.000 --> 00:18.000
     50<v Roger Bingham>from the American Museum of Natural History
     51
     5200:18.000 --> 00:20.000
     53<v Roger Bingham>And with me is Neil deGrasse Tyson
     54
     5500:20.000 --> 00:22.000
     56<v Roger Bingham>Astrophysicist, Director of the Hayden Planetarium
     57
     5800:22.000 --> 00:24.000
     59<v Roger Bingham>at the AMNH.
     60
     6100:24.000 --> 00:26.000
     62<v Roger Bingham>Thank you for walking down here.
     63
     6400:27.000 --> 00:30.000
     65<v Roger Bingham>And I want to do a follow-up on the last conversation we did.
     66
     6700:30.000 --> 00:31.500 align:right size:50%
     68<v Roger Bingham>When we e-mailed—
     69
     7000:30.500 --> 00:32.500 align:left size:50%
     71<v Neil deGrasse Tyson>Didn’t we talk about enough in that conversation?
     72
     7300:32.000 --> 00:35.500 align:right size:50%
     74<v Roger Bingham>No! No no no no; 'cos 'cos obviously 'cos
     75
     7600:32.500 --> 00:33.500 align:left size:50%
     77<v Neil deGrasse Tyson><i>Laughs</i>
     78
     7900: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 { 
    12301230        }
    12311231
    12321232        /**
    1233          * Data profider for test_wp_get_image_mime();
     1233         * Data provider for test_wp_get_image_mime();
    12341234         */
    12351235        public function _wp_get_image_mime() {
    12361236                $data = array(
    class Tests_Functions extends WP_UnitTestCase { 
    13361336                                        'proper_filename' => false,
    13371337                                ),
    13381338                        ),
     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                        ),
    13391378                );
    13401379
    13411380                // Test a few additional file types on single sites.