WordPress.org

Make WordPress Core

Changeset 41318


Ignore:
Timestamp:
08/25/17 23:27:55 (3 months ago)
Author:
SergeyBiryukov
Message:

Formatting: In sanitize_title_with_dashes(), convert forward slash to hyphen on save.

Props corvidism, jtsternberg, GhostToast, alxndr.
Fixes #10792.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r41109 r41318  
    20012001        // Convert nbsp, ndash and mdash HTML entities to hyphens 
    20022002        $title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title ); 
     2003        // Convert forward slash to hyphen 
     2004        $title = str_replace( '/', '-', $title ); 
    20032005 
    20042006        // Strip these characters entirely 
  • trunk/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php

    r36775 r41318  
    110110 
    111111    /** 
     112     * @ticket 10792 
     113     */ 
     114    function test_replaces_forward_slash() { 
     115        $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon/McCartney", '', 'save')); 
     116        $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon//McCartney", '', 'save')); 
     117        $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon///McCartney", '', 'save')); 
     118        $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("songs by Lennon/-McCartney", '', 'save')); 
     119        $this->assertEquals("songs-by-lennon-mccartney", sanitize_title_with_dashes("//songs by Lennon/McCartney", '', 'save')); 
     120    } 
     121 
     122    /** 
    112123     * @ticket 19820 
    113124     */ 
Note: See TracChangeset for help on using the changeset viewer.