Skip to:

[bug] Tags are truncated if being added with mbstring.func_overload

  • Hi!

    I was trying to integrate a bbpress-1.0.2 forum with my existing WP installation and I found a funny bug.

    If I open a topic and use the interface right to the title to add a russian-language tag, only the first half of a tag is actually added.

    If I try to add a tag “mama” (written in russian, of course. I write here in english just for the english speaking people being able to read the post) only the first half of a tag (“ma”) is actually added. It happens everytime I add a tag with an even number of letters (2, 4, 6, etc). Tags with an odd number of letters are added correctly.

    BTW every russian letter in UTF-8 is encoded using exactly two bytes.

    Unfortunatelly, I don’t fully understand what the code does and the below is just my guess.

    I guess the problem is in file /bb-includes/ either in function seems_utf8() or in bb_utf8_cut().

    Traditionally, strlen() returned 8 for utf-8-encoded “mama”. In such case bb_utf8_cut() would work correct (althought I haven’t actually checked). But if one use php.ini mbstring.func_overload option to overload str* functions by mb_str* ones, then strlen(“mama”) returns 4 and bb_utf8_cut() thinks this’s is non-utf-8-encoded string length and assumes that the “actual” string length would be 2. That’s wrong.

    So, my general suggestions is to fix somehow one of those functions to work correctly with mbstring.func_overload both set and unset.

    The quick-fix for people having the option set is to add the following line at the very start of bb_utf8_cut() function:

    return $utf8_string;

    1. Am I correct or should I search for the problem in another piece of the system?

    2. Would this “fix” break anything else?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar