diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php
index 8be3f79d56..fae60cdd95 100644
--- a/src/wp-includes/kses.php
+++ b/src/wp-includes/kses.php
@@ -781,7 +781,7 @@ function wp_kses_split2($string, $allowed_html, $allowed_protocols) {
}
// Allow HTML comments
- if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches))
+ if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9-]+)([^>]*)>?$%', $string, $matches))
return '';
// It's seriously malformed
diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php
index e105813449..c9cf5d01db 100644
--- a/tests/phpunit/tests/kses.php
+++ b/tests/phpunit/tests/kses.php
@@ -360,6 +360,20 @@ EOF;
$this->assertEquals( $allowedtags, wp_kses_allowed_html( 'data' ) );
}
+ function test_hyphenated_tag() {
+ $string = "Alot of hyphens.";
+ $custom_tags = array(
+ 'hyphenated-tag' => array(
+ 'attribute' => true,
+ ),
+ );
+ $expect_stripped_string = 'Alot of hyphens.';
+
+ $expect_valid_string = "Alot of hyphens.";
+ $this->assertEquals( $expect_stripped_string, wp_kses_post( $string ) );
+ $this->assertEquals( $expect_valid_string, wp_kses( $string, $custom_tags ) );
+ }
+
/**
* @ticket 26290
*/