Changeset 36775
- Timestamp:
- 02/29/2016 04:41:03 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r36578 r36775 1585 1585 1586 1586 $title = strtolower($title); 1587 $title = preg_replace('/&.+?;/', '', $title); // kill entities1588 $title = str_replace('.', '-', $title);1589 1587 1590 1588 if ( 'save' == $context ) { 1591 1589 // Convert nbsp, ndash and mdash to hyphens 1592 1590 $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 ); 1593 1593 1594 1594 // Strip these characters entirely … … 1612 1612 $title = str_replace( '%c3%97', 'x', $title ); 1613 1613 } 1614 1615 $title = preg_replace('/&.+?;/', '', $title); // kill entities 1616 $title = str_replace('.', '-', $title); 1614 1617 1615 1618 $title = preg_replace('/[^%a-z0-9 _-]/', '', $title); -
trunk/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php
r30515 r36775 64 64 } 65 65 66 /** 67 * @ticket 31790 68 */ 69 function test_replaces_nbsp_entities() { 70 $this->assertEquals("dont-break-the-space", sanitize_title_with_dashes("don't break the space", '', 'save')); 71 } 72 66 73 function test_replaces_ndash_mdash() { 67 74 $this->assertEquals("do-the-dash", sanitize_title_with_dashes("Do – the Dash", '', 'save')); 68 75 $this->assertEquals("do-the-dash", sanitize_title_with_dashes("Do the — Dash", '', 'save')); 76 } 77 78 /** 79 * @ticket 31790 80 */ 81 function test_replaces_ndash_mdash_entities() { 82 $this->assertEquals("do-the-dash", sanitize_title_with_dashes("Do – the – Dash", '', 'save')); 83 $this->assertEquals("do-the-dash", sanitize_title_with_dashes("Do — the — Dash", '', 'save')); 69 84 } 70 85
Note: See TracChangeset
for help on using the changeset viewer.