diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index eb67e4827e..b9de5273d7 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -2000,6 +2000,8 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa $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 forward slash to hyphen + $title = str_replace( '/', '-', $title ); // Strip these characters entirely $title = str_replace( array( diff --git a/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php b/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php index d0797e2da7..20c1026d6f 100644 --- a/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php +++ b/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php @@ -108,6 +108,17 @@ class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { $this->assertEquals("just-a-slug", sanitize_title_with_dashes("Just ™ a Slug", '', 'save')); } + /** + * @ticket 10792 + */ + function test_replaces_forward_slash() { + $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon/McCartney", '', 'save')); + $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon//McCartney", '', 'save')); + $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon///McCartney", '', 'save')); + $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon/-McCartney", '', 'save')); + $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("//songs by Lennon/McCartney", '', 'save')); + } + /** * @ticket 19820 */