Skip to content
Closed
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
8 changes: 4 additions & 4 deletions src/wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -2294,10 +2294,10 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa
$title = strtolower( $title );

if ( 'save' === $context ) {
// Convert &nbsp, &ndash, and &mdash to hyphens.
$title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );
// Convert &nbsp, &ndash, and &mdash HTML entities to hyphens.
$title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title );
// Convert &nbsp, non-breaking hyphen, &ndash, and &mdash to hyphens.
$title = str_replace( array( '%c2%a0', '%e2%80%91', '%e2%80%93', '%e2%80%94' ), '-', $title );
// Convert &nbsp, non-breaking hyphen, &ndash, and &mdash HTML entities to hyphens.
$title = str_replace( array( ' ', '‑', ' ', '–', '–', '—', '—' ), '-', $title );
// Convert forward slash to hyphen.
$title = str_replace( '/', '-', $title );

Expand Down
14 changes: 14 additions & 0 deletions tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ public function test_replaces_ndash_mdash_entities() {
$this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do — the — Dash', '', 'save' ) );
}

/**
* @ticket 64089
*/
public function test_replaces_non_breaking_hyphen() {
$this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do‑the Dash', '', 'save' ) );
}

/**
* @ticket 64089
*/
public function test_replaces_non_breaking_hyphen_entity() {
$this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do ‑ the Dash', '', 'save' ) );
}

public function test_replaces_iexcel_iquest() {
$this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just ¡a Slug', '', 'save' ) );
$this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just a Slug¿', '', 'save' ) );
Expand Down
Loading