Make WordPress Core


Ignore:
Timestamp:
06/19/2015 06:46:11 PM (11 years ago)
Author:
wonderboymusic
Message:

Don't strip \0 (backslash+zero) from post content for users without "unfiltered_html"

Adds unit tests.

Props miqrogroove.
Fixes #28699.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/kses.php

    r28942 r32860  
    412412                );
    413413        }
     414       
     415        /**
     416         * Test removal of '\0' strings.
     417         *
     418         * @ticket 28699
     419         * @dataProvider data_slash_zero_removal
     420         */
     421        function test_slash_zero_removal( $input, $output ) {
     422                global $allowedposttags;
     423
     424                return $this->assertEquals( $output, wp_kses( $input, $allowedposttags ) );
     425        }
     426       
     427        function data_slash_zero_removal() {
     428                return array(
     429                        array(
     430                                'This \\0 should be no big deal.',
     431                                'This \\0 should be no big deal.',
     432                        ),
     433                        array(
     434                                '<div>This \\0 should be no big deal.</div>',
     435                                '<div>This \\0 should be no big deal.</div>',
     436                        ),
     437                        array(
     438                                '<div align="\\0left">This should be no big deal.</div>',
     439                                '<div align="\\0left">This should be no big deal.</div>',
     440                        ),
     441                        array(
     442                                'This <div style="float:\\0left"> is more of a concern.',
     443                                'This <div style="float:left"> is more of a concern.',
     444                        ),
     445                        array(
     446                                'This <div style="float:\\0\\0left"> is more of a concern.',
     447                                'This <div style="float:left"> is more of a concern.',
     448                        ),
     449                        array(
     450                                'This <div style="float:\\\\00left"> is more of a concern.',
     451                                'This <div style="float:left"> is more of a concern.',
     452                        ),
     453                        array(
     454                                'This <div style="float:\\\\\\\\0000left"> is more of a concern.',
     455                                'This <div style="float:left"> is more of a concern.',
     456                        ),
     457                        array(
     458                                'This <div style="float:\\0000left"> is more of a concern.',
     459                                'This <div style="float:left"> is more of a concern.',
     460                        ),
     461                        array(
     462                                '<style type="text/css">div {background-image:\\0}</style>',
     463                                'div {background-image:\\0}',
     464                        ),
     465                );
     466        }
    414467}
Note: See TracChangeset for help on using the changeset viewer.