Make WordPress Core


Ignore:
Timestamp:
09/02/2016 04:16:00 AM (9 years ago)
Author:
jorbin
Message:

Formatting: Allow KSES custom elements with hyphens

The W3C Custom Elements spec (http://www.w3.org/TR/custom-elements/#concepts) allows you to use your own custom DOM elements/tags. One of the main requirements is that the tag name "must contain a U+002D HYPHEN-MINUS character". This adjusts KSES to allow it.

Fixes #34105.
Props batmoo.

File:
1 edited

Legend:

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

    r35960 r38511  
    361361    }
    362362
     363    function test_hyphenated_tag() {
     364        $string = "<hyphenated-tag attribute=\"value\" otherattribute=\"value2\">Alot of hyphens.</hyphenated-tag>";
     365        $custom_tags = array(
     366            'hyphenated-tag' => array(
     367                'attribute' => true,
     368            ),
     369        );
     370        $expect_stripped_string = 'Alot of hyphens.';
     371
     372        $expect_valid_string = "<hyphenated-tag attribute=\"value\">Alot of hyphens.</hyphenated-tag>";
     373        $this->assertEquals( $expect_stripped_string, wp_kses_post( $string ) );
     374        $this->assertEquals( $expect_valid_string, wp_kses( $string, $custom_tags ) );
     375    }
     376
    363377    /**
    364378     * @ticket 26290
Note: See TracChangeset for help on using the changeset viewer.