WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#12956 closed enhancement (duplicate)

© and ™ not stripped from sanitize_title

Reported by: thomask Owned by: ryan
Milestone: Priority: normal
Severity: normal Version:
Component: Permalinks Keywords:
Focuses: Cc:

Description

© and ™ (© ™) and probably many other symbols are not stripped out when sanitizing title.

quick workaround:

function mc_sanitize_title( $title ) {
	return str_replace(array("%e2%84%a2", "%c2%a9"), "", $title);
}
add_filter('sanitize_title', 'mc_sanitize_title');

but i guess that there should be some most robust and standard solution, e.g. using PHP transliteration first and then removing anything but alphanumeric, coma and underscore like in this function

function friendly_url($raw_title) {
    $url = $raw_title;
    $url = preg_replace('~[^\\pL0-9_]+~u', '-', $url);
    $url = trim($url, "-");
    $url = iconv("utf-8", "us-ascii//TRANSLIT", $url);
    $url = strtolower($url);
    $url = preg_replace('~[^-a-z0-9_]+~', '', $url);
    return $url;
}

this should also create nice url even for special alphabets. (setlocale must be set, but imho it is somewhere in wordpress core)

Change History (6)

comment:1 @unsalkorkmaz5 years ago

  • Cc unsalkorkmaz added

comment:3 @sivel5 years ago

  • Milestone changed from 3.0 to 3.1
  • Type changed from defect (bug) to enhancement
  • Version 3.0 deleted

Punting to 3.1.

comment:4 @hakre5 years ago

I wonder if those chars should be stripped at all. They look valid in a posts, title, aren't they?

comment:5 @nacin4 years ago

  • Milestone changed from Awaiting Triage to Future Release

comment:6 @SergeyBiryukov4 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Merged into the patch in #10797.

Note: See TracTickets for help on using tickets.