Ticket #1474 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

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

Reported by: zet Assigned to: skippy
Priority: normal Milestone:
Component: General Version: 1.6
Severity: minor Keywords: bg|has-patch bg|2nd-opinion
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

06/28/05 09:38:54 changed by zet

  • component changed from Administration to General.

07/01/05 20:01:48 changed by skippy

  • keywords set to bg|has-patch bg|2nd-opinion.
  • owner changed from anonymous to skippy.
  • status changed from new to assigned.

Seems like a good idea. Any subtle gotchas ?

11/16/05 09:38:56 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

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