The WEIGHT feature incorrectly truncates UTF-8 strings

aleko74 - March 8, 2009 - 08:04
Project:Frequently Asked Questions
Version:6.x-1.8
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Nice module first of all! Just what I need for my site. Now a bug report...

My site is in Russian so are the frequently asked questions. I began entering questions and then I went to the Weight tab. The list displayed some questions but not others. The problem is incorrect truncation of multibyte strings in the following piece of code in faq_weight_settings_form(), which can generate invalid UTF-8 sequence:

    while ($node = db_fetch_object($result)) {
      $title = (drupal_strlen($node->title) <= 64) ? $node->title : substr_replace($node->title, "...", 63);
      $options[$node->nid] = $title;
      $order .= "$node->nid,";
    }
    $order = rtrim($order, ",");

To fix the problem, the following line:
      $title = (drupal_strlen($node->title) <= 64) ? $node->title : substr_replace($node->title, "...", 63);
should be replaced with something like:
      $title = (drupal_strlen($node->title) <= 64) ? $node->title : drupal_substr($node->title, 0, 63) . "...";

#1

andyceo - October 7, 2009 - 13:45

Subscribing. We have the same error! Please, commit this issue.

#2

andyceo - October 7, 2009 - 13:56
Version:5.x-2.12» 6.x-1.8

But we have another version of this module.

#3

stella - October 26, 2009 - 04:40
Status:active» fixed

Committed, thanks!

#4

System Message - November 9, 2009 - 04:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#5

stella - November 24, 2009 - 17:07

Released in faq 6.x-1.9 and 5.x-2.13.

 
 

Drupal is a registered trademark of Dries Buytaert.