Make WordPress Core

Ticket #30883: patch.diff

File patch.diff, 1.6 KB (added by sgrant, 10 years ago)
  • src/wp-includes/formatting.php

     
    13531353        if ( '' == $sanitized )
    13541354                $sanitized = $fallback;
    13551355
     1356        if ( substr_count( $sanitized, '-' ) == strlen( $sanitized ) )
     1357                $sanitized = $fallback;
     1358
    13561359        /**
    13571360         * Filter a sanitized HTML class string.
    13581361         *
  • tests/phpunit/tests/formatting/SanitizeHtmlClass.php

     
     1<?php
     2
     3/**
     4 * @group formatting
     5 */
     6class Tests_Formatting_SanitizeHtmlClass extends WP_UnitTestCase {
     7
     8        /**
     9         * @covers ::sanitize_html_class
     10         */
     11        public function test_fallback_empty() {
     12                $result = sanitize_html_class( '' );
     13                $this->assertEquals( '', $result );
     14        }
     15
     16        /**
     17         * @covers ::sanitize_html_class
     18         */
     19        public function test_fallback_with_only_hyphens() {
     20                $result = sanitize_html_class( '---' );
     21                $this->assertEquals( '', $result );
     22        }
     23
     24        /**
     25         * @covers ::sanitize_html_class
     26         * @ticket 30883
     27         */
     28        public function test_fallback_hyphens_after_percent_encoded_octets() {
     29                $s1 = sanitize_html_class( '%d0%b2%d1%82%d0%be%d1%80%d0%b0%d1%8f-%d1%80%d1%83%d0%b1%d1%80%d0%b8%d0%ba%d0%b0' );
     30                $s2 = sanitize_html_class( '%d0%bf%d0%b5%d1%80%d0%b2%d0%b0%d1%8f-%d1%80%d1%83%d0%b1%d1%80%d0%b8%d0%ba%d0%b0' );
     31
     32                $this->assertEquals( '', $s1 );
     33                $this->assertEquals( '', $s2 );
     34        }
     35
     36}