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
3 changes: 3 additions & 0 deletions src/wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -2284,6 +2284,9 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa
// Restore octets.
$title = preg_replace( '|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title );

// Convert multiplication sign and times entities to 'x'.
$title = str_replace( array( '×', '×', '×' ), 'x', $title );
Comment on lines +2287 to +2288
Copy link
Member

@westonruter westonruter Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this be added here as opposed to being added right after the existing:

// Convert &times to 'x'.
$title = str_replace( '%c3%97', 'x', $title );


if ( wp_is_valid_utf8( $title ) ) {
if ( function_exists( 'mb_strtolower' ) ) {
$title = mb_strtolower( $title, 'UTF-8' );
Expand Down
34 changes: 33 additions & 1 deletion tests/phpunit/tests/formatting/sanitizeTitleWithDashes.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,39 @@ public function test_replaces_forward_slash() {
* @ticket 19820
*/
public function test_replaces_multiply_sign() {
$this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ) );
$this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ), 'Multiplication sign (×) should be replaced with letter x' );
}

/**
* @ticket 64284
*/
public function test_replaces_multiply_sign_with_spaces() {
$this->assertSame( 'iphone-12-x-256gb', sanitize_title_with_dashes( 'iPhone 12 × 256GB', '', 'save' ), 'Product title with multiplication sign and spaces should convert × to x' );
$this->assertSame( 'screen-1920-x-1080', sanitize_title_with_dashes( 'Screen 1920 × 1080', '', 'save' ), 'Screen dimensions with multiplication sign should convert × to x' );
}

/**
* @ticket 64284
*/
public function test_replaces_times_html_entity() {
$this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ), 'HTML entity × should be replaced with letter x' );
$this->assertSame( 'product-5x10', sanitize_title_with_dashes( 'Product 5×10', '', 'save' ), 'HTML entity × without spaces should be replaced with letter x' );
}

/**
* @ticket 64284
*/
public function test_replaces_times_numeric_entity() {
$this->assertSame( '3x4-equals-12', sanitize_title_with_dashes( '3×4 equals 12', '', 'save' ), 'Numeric HTML entity × should be replaced with letter x' );
}

/**
* @ticket 64284
*/
public function test_replaces_multiply_sign_in_display_context() {
// Should work in display context too, not just 'save'.
$this->assertSame( '6x7', sanitize_title_with_dashes( '6×7', '', 'display' ), 'Multiplication sign should be replaced with x in display context' );
$this->assertSame( 'testx', sanitize_title_with_dashes( 'test×', '' ), 'Multiplication sign should be replaced with x when context is not specified' );
}

/**
Expand Down
Loading