Make WordPress Core


Ignore:
Timestamp:
02/29/2016 04:41:03 AM (11 years ago)
Author:
SergeyBiryukov
Message:

Formatting: In sanitize_title_with_dashes(), convert &nbsp, &ndash, and &mdash HTML entities to hyphens on save.

Props polevaultweb for initial patch.
Fixes #31790.

File:
1 edited

Legend:

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

    r36578 r36775  
    15851585
    15861586        $title = strtolower($title);
    1587         $title = preg_replace('/&.+?;/', '', $title); // kill entities
    1588         $title = str_replace('.', '-', $title);
    15891587
    15901588        if ( 'save' == $context ) {
    15911589                // Convert nbsp, ndash and mdash to hyphens
    15921590                $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );
     1591                // Convert nbsp, ndash and mdash HTML entities to hyphens
     1592                $title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title );
    15931593
    15941594                // Strip these characters entirely
    … …  
    16121612                $title = str_replace( '%c3%97', 'x', $title );
    16131613        }
     1614
     1615        $title = preg_replace('/&.+?;/', '', $title); // kill entities
     1616        $title = str_replace('.', '-', $title);
    16141617
    16151618        $title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
Note: See TracChangeset for help on using the changeset viewer.