WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#1474 closed defect (bug) (fixed)

Incorrect string cut for localized title and excerpt in wp_trackback.php.

Reported by: zet Owned by: skippy
Milestone: Priority: normal
Severity: minor Version: 1.6
Component: General Keywords: bg|has-patch bg|2nd-opinion
Focuses: Cc:

Description

Somewhere in wp_trackback.php (string 71,72,73):

$title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
$excerpt = strip_tags($excerpt);
$excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;

Function substr working properly only for english UTF-8 strings because codes of latin letters in ASCII same to UTF-8. But for cyrillic and other national symbols function substr works incorrectly.
I recommend replace all substr inclusions for language-sensitive data with function wp_substr():

function wp_substr() {
        $function (function_exists('mb_substr'))?'mb_substr':'substr';
        return call_user_func_array($function, func_get_args());
}

Change History (3)

comment:1 zet9 years ago

  • Component changed from Administration to General

comment:2 skippy9 years ago

  • Keywords bg|has-patch bg|2nd-opinion added
  • Owner changed from anonymous to skippy
  • Status changed from new to assigned

Seems like a good idea. Any subtle gotchas ?

comment:3 ryan8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [3107]) Use mb_substr for trackback titles. Props zet. fixes #1474

Note: See TracTickets for help on using tickets.