WordPress.org

Make WordPress Core

Ticket #45615: 45615.3.diff

File 45615.3.diff, 9.0 KB (added by tellyworth, 6 months ago)

Incremental fix and unit tests

  • src/wp-includes/functions.php

     
    23772377                        if ( substr( $real_mime, 0, strcspn( $real_mime, '/' ) ) !== substr( $type, 0, strcspn( $type, '/' ) ) ) {
    23782378                                $type = $ext = false;
    23792379                        }
     2380                } elseif ( 'text/plain' === $real_mime ) {
     2381                        // A few common file types are occasionally detected as text/plain; allow those.
     2382                        if ( !in_array( $type, array( 'text/plain', 'text/csv', 'text/tsv', 'application/json' ) ) ) {
     2383                                $type = $ext = false;
     2384                        }
    23802385                } else {
    23812386                        if ( $type !== $real_mime ) {
    23822387                                /*
  • tests/phpunit/data/uploads/test.csv

     
     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 No newline at end of file
  • tests/phpunit/data/uploads/test.dfxp

     
     1<?xml version="1.0" encoding="utf-8"?>
     2<tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml"
     3        xmlns:tts="http://www.w3.org/ns/ttml#styling"
     4        xmlns:ttm="http://www.w3.org/ns/ttml#metadata">
     5        <head>
     6                <styling>
     7                        <style xml:id="defaultCaption" tts:fontSize="10" tts:fontFamily="SansSerif"
     8                        tts:fontWeight="normal" tts:fontStyle="normal"
     9                        tts:textDecoration="none" tts:color="white"
     10                        tts:backgroundColor="black" />
     11                </styling>
     12
     13        </head>
     14        <body>
     15                <div style="defaultCaption" xml:lang="en">
     16                        <p begin="00:00:03.400" end="00:00:06.177">In this lesson, we're going to<br />be talking about finance. And</p>
     17                        <p begin="00:00:06.177" end="00:00:10.009">one of the most important aspects<br />of finance is interest.</p>
     18                        <p begin="00:00:10.009" end="00:00:13.655">When I go to a bank or some<br />other lending institution</p>
     19                        <p begin="00:00:13.655" end="00:00:17.720">to borrow money, the bank is happy<br />to give me that money. But then I'm</p>
     20                        <p begin="00:00:17.900" end="00:00:21.480">going to be paying the bank for the<br />privilege of using their money. And that</p>
     21                        <p begin="00:00:21.660" end="00:00:26.440">amount of money that I pay the bank is<br />called interest. Likewise, if I put money</p>
     22                        <p begin="00:00:26.620" end="00:00:31.220">in a savings account or I purchase a<br />certificate of deposit, the bank just</p>
     23                        <p begin="00:00:31.300" end="00:00:35.800">doesn't put my money in a little box<br />and leave it there until later. They take</p>
     24                        <p begin="00:00:35.800" end="00:00:40.822">my money and lend it to someone<br />else. So they are using my money.</p>
     25                        <p begin="00:00:40.822" end="00:00:44.400">The bank has to pay me for the privilege<br />of using my money.</p>
     26                        <p begin="00:00:44.400" end="00:00:48.700">Now what makes banks<br />profitable is the rate</p>
     27                        <p begin="00:00:48.700" end="00:00:53.330">that they charge people to use the bank's<br />money is higher than the rate that they</p>
     28                        <p begin="00:00:53.510" end="00:01:00.720">pay people like me to use my money. The<br />amount of interest that a person pays or</p>
     29                        <p begin="00:01:00.800" end="00:01:06.640">earns is dependent on three things. It's<br />dependent on how much money is involved.</p>
     30                        <p begin="00:01:06.820" end="00:01:11.300">It's dependent upon the rate of interest<br />being paid or the rate of interest being</p>
     31                        <p begin="00:01:11.480" end="00:01:17.898">charged. And it's also dependent upon<br />how much time is involved. If I have</p>
     32                        <p begin="00:01:17.898" end="00:01:22.730">a loan and I want to decrease the amount<br />of interest that I'm going to pay, then</p>
     33                        <p begin="00:01:22.800" end="00:01:28.040">I'm either going to have to decrease how<br />much money I borrow, I'm going to have</p>
     34                        <p begin="00:01:28.220" end="00:01:32.420">to borrow the money over a shorter period<br />of time, or I'm going to have to find a</p>
     35                        <p begin="00:01:32.600" end="00:01:37.279">lending institution that charges a lower<br />interest rate. On the other hand, if I</p>
     36                        <p begin="00:01:37.279" end="00:01:41.480">want to earn more interest on my<br />investment, I'm going to have to invest</p>
     37                        <p begin="00:01:41.480" end="00:01:46.860">more money, leave the money in the<br />account for a longer period of time, or</p>
     38                        <p begin="00:01:46.860" end="00:01:49.970">find an institution that will pay<br />me a higher interest rate.</p>
     39                </div>
     40        </body>
     41</tt>
  • tests/phpunit/data/uploads/test.json

     
     1{"menu": {
     2  "id": "file",
     3  "value": "File",
     4  "popup": {
     5    "menuitem": [
     6      {"value": "New", "onclick": "CreateNewDoc()"},
     7      {"value": "Open", "onclick": "OpenDoc()"},
     8      {"value": "Close", "onclick": "CloseDoc()"}
     9    ]
     10  }
     11}}
     12 No newline at end of file
  • tests/phpunit/data/uploads/test.tsv

     
     1sample  tsv     file    1
     2some    text    here    2
     3yup     it's    text    3
     4 No newline at end of file
  • tests/phpunit/data/uploads/test.vtt

     
     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.
     41 No newline at end of file
  • tests/phpunit/tests/functions.php

     
    10441044        }
    10451045
    10461046        /**
    1047          * Data profider for test_wp_get_image_mime();
     1047         * Data provider for test_wp_get_image_mime();
    10481048         */
    10491049        public function _wp_get_image_mime() {
    10501050                $data = array(
     
    11501150                                        'proper_filename' => false,
    11511151                                ),
    11521152                        ),
     1153                        // Non-image file not allowed even if it's named like one.
     1154                        array(
     1155                                DIR_TESTDATA . '/export/crazy-cdata.xml',
     1156                                'crazy-cdata.jpg',
     1157                                array(
     1158                                        'ext' => false,
     1159                                        'type' => false,
     1160                                        'proper_filename' => false,
     1161                                ),
     1162                        ),
     1163                        // Non-image file not allowed if it's named like something else.
     1164                        array(
     1165                                DIR_TESTDATA . '/export/crazy-cdata.xml',
     1166                                'crazy-cdata.doc',
     1167                                array(
     1168                                        'ext' => false,
     1169                                        'type' => false,
     1170                                        'proper_filename' => false,
     1171                                ),
     1172                        ),
     1173                        // Assorted text/* sample files
     1174                        array(
     1175                                DIR_TESTDATA . '/uploads/test.vtt',
     1176                                'test.vtt',
     1177                                array(
     1178                                        'ext' => 'vtt',
     1179                                        'type' => 'text/vtt',
     1180                                        'proper_filename' => false,
     1181                                ),
     1182                        ),
     1183                        array(
     1184                                DIR_TESTDATA . '/uploads/test.dfxp',
     1185                                'test.dfxp',
     1186                                array(
     1187                                        'ext' => 'dfxp',
     1188                                        'type' => 'text/dfxp',
     1189                                        'proper_filename' => false,
     1190                                ),
     1191                        ),
     1192                        array(
     1193                                DIR_TESTDATA . '/uploads/test.csv',
     1194                                'test.csv',
     1195                                array(
     1196                                        'ext' => 'csv',
     1197                                        'type' => 'text/csv',
     1198                                        'proper_filename' => false,
     1199                                ),
     1200                        ),
     1201                        array(
     1202                                DIR_TESTDATA . '/uploads/test.json',
     1203                                'test.json',
     1204                                array(
     1205                                        'ext' => 'json',
     1206                                        'type' => 'application/json',
     1207                                        'proper_filename' => false,
     1208                                ),
     1209                        ),
    11531210                );
    11541211
    11551212                // Test a few additional file types on single sites.