Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -2507,6 +2507,13 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa
'%cc%80',
'%cc%84',
'%cc%8c',
// CJK punctuation.
'%e3%80%82', // 。 (U+3002, Ideographic Full Stop)
'%ef%bc%8c', // , (U+FF0C, Fullwidth Comma)
'%ef%bc%81', // ! (U+FF01, Fullwidth Exclamation Mark)
'%ef%bc%9a', // : (U+FF1A, Fullwidth Colon)
'%e3%80%8a', // 《 (U+300A, Left Double Angle Bracket)
'%e3%80%8b', // 》 (U+300B, Right Double Angle Bracket)
// Non-visible characters that display without a width.
'%e2%80%8b', // Zero width space.
'%e2%80%8c', // Zero width non-joiner.
Expand Down
23 changes: 23 additions & 0 deletions tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,27 @@ public function data_non_visible_characters_with_width_to_hyphen_when_not_save()
),
);
}

/**
* @ticket 22402
*/
public function test_strips_cjk_punctuation() {
$this->assertSame( 'hello-world', sanitize_title_with_dashes( 'Hello World。', '', 'save' ) );
$this->assertSame( 'testtitle', sanitize_title_with_dashes( 'Test,Title', '', 'save' ) );
$this->assertSame( 'amazingpost', sanitize_title_with_dashes( 'Amazing!Post', '', 'save' ) );
$this->assertSame( 'greatcontent', sanitize_title_with_dashes( 'Great:Content', '', 'save' ) );
$this->assertSame( 'booktitle', sanitize_title_with_dashes( '《Book》Title', '', 'save' ) );
$this->assertSame( 'mixedpunctuation', sanitize_title_with_dashes( 'Mixed。,!:《》Punctuation', '', 'save' ) );
}

/**
* @ticket 22402
*/
public function test_preserves_cjk_punctuation_when_not_save() {
$this->assertSame( 'hello-world%e3%80%82', sanitize_title_with_dashes( 'Hello World。' ) );
$this->assertSame( 'test%ef%bc%8ctitle', sanitize_title_with_dashes( 'Test,Title' ) );
$this->assertSame( 'amazing%ef%bc%81post', sanitize_title_with_dashes( 'Amazing!Post' ) );
$this->assertSame( 'great%ef%bc%9acontent', sanitize_title_with_dashes( 'Great:Content' ) );
$this->assertSame( '%e3%80%8abook%e3%80%8btitle', sanitize_title_with_dashes( '《Book》Title' ) );
}
}
Loading