Make WordPress Core


Ignore:
Timestamp:
07/14/2015 05:55:07 PM (11 years ago)
Author:
wonderboymusic
Message:

After [33148]:
Don't nest esc_attr() and htmlspecialchars() when escaping the post title on the edit post screen.

Unrevert parts of [32851] and [32850].

Adds/alters unit tests.

Props miqrogroove.
Fixes #17780.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/WPSpecialchars.php

    r33148 r33271  
    1818                // Allowed entities should be unchanged
    1919                foreach ( $allowedentitynames as $ent ) {
     20                        if ( 'apos' == $ent ) {
     21                                // But for some reason, PHP doesn't allow '
     22                                continue;
     23                        }
    2024                        $ent = '&' . $ent . ';';
    2125                        $this->assertEquals( $ent, _wp_specialchars( $ent ) );
     
    4044                $this->assertEquals( $source, _wp_specialchars($source) );
    4145        }
     46
     47        /**
     48         * Check some of the double-encoding features for entity references.
     49         *
     50         * @ticket 17780
     51         * @dataProvider data_double_encoding
     52         */
     53        function test_double_encoding( $input, $output ) {
     54                return $this->assertEquals( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, true ) );
     55        }
     56
     57        function data_double_encoding() {
     58                return array(
     59                        array(
     60                                'This & that, this & that, — " " Ú   " " " " " $ ×',
     61                                'This & that, this & that, — " " Ú   " " " " " $ ×',
     62                        ),
     63                        array(
     64                                '&& && && &;',
     65                                '&& && && &;',
     66                        ),
     67                        array(
     68                                '&garbage; &***; &aaaa; &0000; &####; &;;',
     69                                '&garbage; &***; &aaaa; &0000; &####; &;;',
     70                        ),
     71                );
     72        }
     73
     74        /**
     75         * Check some of the double-encoding features for entity references.
     76         *
     77         * @ticket 17780
     78         * @dataProvider data_no_double_encoding
     79         */
     80        function test_no_double_encoding( $input, $output ) {
     81                return $this->assertEquals( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, false ) );
     82        }
     83
     84        function data_no_double_encoding() {
     85                return array(
     86                        array(
     87                                'This & that, this & that, — " " Ú   " " " " " $ ×',
     88                                'This & that, this & that, — " " Ú   " " " " " $ ×',
     89                        ),
     90                        array(
     91                                '&& && && &;',
     92                                '&& && && &;',
     93                        ),
     94                        array(
     95                                '&garbage; &***; &aaaa; &0000; &####; &;;',
     96                                '&garbage; &***; &aaaa; &0000; &####; &;;',
     97                        ),
     98                );
     99        }
    42100}
Note: See TracChangeset for help on using the changeset viewer.