Make WordPress Core

Ticket #24157: kses.diff

File kses.diff, 1.3 KB (added by joehoyle, 10 years ago)

Unit tests for safecss_filter_attr

  • tests/kses.php

     
    359359                $this->assertEquals( $allowedposttags, wp_kses_allowed_html( 'post' ) );
    360360                $this->assertEquals( $allowedtags, wp_kses_allowed_html( 'data' ) );
    361361        }
     362
     363        /**
     364         * @ticket 24157
     365         * @group test_safecss_filter_attr
     366         */
     367        function test_safecss_filter_attr() {
     368
     369                // "normal" css
     370                $css = 'font-weight: bold';
     371                $this->assertEquals( safecss_filter_attr( $css ), 'font-weight: bold' );
     372
     373                // multiple properties
     374                $css = 'font-weight: bold; color: red';
     375                $this->assertEquals( safecss_filter_attr( $css ), 'font-weight: bold;color: red' );
     376
     377                // values with #
     378                $css = 'color: #333333';
     379                $this->assertEquals( safecss_filter_attr( $css ), 'color: #333333' );
     380
     381                // fail on css expression
     382                $css = 'height: expression( body.scrollTop + 50 + "px" )';
     383                $this->assertEquals( safecss_filter_attr( $css ), '' );
     384
     385                // values rgb color
     386                $css = 'color: rgb( 100, 100, 100 )';
     387                $this->assertEquals( safecss_filter_attr( $css ), 'color: rgb( 100, 100, 100 )' );
     388
     389                // values rgba color
     390                $css = 'color: rgba( 100, 100, 100 )';
     391                $this->assertEquals( safecss_filter_attr( $css ), 'color: rgb( 100, 100, 100, .4 )' );
     392        }
    362393}