Skip to:
Content

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#1253 closed defect (worksforme)

Tags are truncated if being added with mbstring.func_overload

Reported by: pv4 Owned by:
Milestone: 1.0.3 Priority: normal
Severity: normal Version: 1.0.2
Component: i18n/l10n Keywords: reporter-feedback
Cc:

Description

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/functions.bb-formatting.php 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?
  1. Would this "fix" break anything else?

Change History (6)

comment:1 pv44 years ago

  • Summary changed from Nags are truncated if being added with mbstring.func_overload to Tags are truncated if being added with mbstring.func_overload

comment:2 Gautam Gupta4 years ago

  • Milestone set to 1.0.3

comment:3 GautamGupta4 years ago

  • Keywords needs-patch added

comment:4 GautamGupta4 years ago

  • Keywords reporter-feedback added; needs-patch removed
  • Resolution set to worksforme
  • Status changed from new to closed

I just google translated the "mama" word into russian language and tested it by adding it into the tags. It worked fine. Can you please tell if it still happens with you or if you don't have a normal install, eg. it is integrated?

comment:5 GautamGupta4 years ago

Oh, you have mentioned that is integrated, is it only because of that?

comment:6 GautamGupta4 years ago

Ok, now I also tested this on an integrated install and it worked fine for me even there. Reopen the ticket if the problem still exists and also the WordPress version you are using.

Note: See TracTickets for help on using tickets.