Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#2769 closed Bug (fixed)

Truncation should handle UTF-8 (multi-byte encoding)

Reported by: codax Owned by: vipsoft
Priority: major Milestone: 1.7 Piwik 1.7
Component: Core Keywords:
Cc: matthieu.aubry@… Sensitive: no

Description

This patch fixes a bug in the 'truncate' function (core function) where PHP function 'substr' have been working incorrectly with the 'utf-8' Cyrillic encoding.

That was causing the '�' symbol appearing in the end of page titles being cut. For example, we found the bug in 'Visitors' > 'Visitor Log' section.

So the patch replaces the 'substr' fucntion with the 'mb_substr' and 'utf-8' and the bug then goes away.

Attachments (3)

truncate.patch (1.0 KB) - added by codax 2 years ago.
truncate.2.patch (1.0 KB) - added by codax 2 years ago.
encode patch for mbstrings
mbstringsDetectEncode.patch (1.8 KB) - added by codax 2 years ago.

Download all attachments as: .zip

Change History (13)

Changed 2 years ago by codax

comment:1 Changed 2 years ago by vipsoft (robocoder)

  • Keywords cyrillic truncate substr bug removed
  • Milestone changed from 1.x - Piwik 1.x to 1.6.x Piwik 1.6.x
  • Owner set to vipsoft

thanks; the only change to the patch would be to handle case where mbstring extension may not be present

comment:2 Changed 2 years ago by vipsoft (robocoder)

  • Summary changed from Core patch to fix a little bug in the 'truncate' function to Truncation should handle UTF-8

comment:3 Changed 2 years ago by vipsoft (robocoder)

  • Summary changed from Truncation should handle UTF-8 to Truncation should handle UTF-8 (multi-byte encoding)

comment:4 Changed 2 years ago by vipsoft (robocoder)

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

(In [5427]) fixes #2769

comment:5 Changed 2 years ago by matt (mattab)

codax thanks for the patch, and vipsoft thanks for super fast commit ;)

Changed 2 years ago by codax

encode patch for mbstrings

Changed 2 years ago by codax

comment:6 Changed 2 years ago by vipsoft (robocoder)

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:7 Changed 2 years ago by vipsoft (robocoder)

(In [5430]) refs #2769 - revert this patch

comment:8 Changed 2 years ago by vipsoft (robocoder)

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

(In [5431]) fixes #2769 plus refactoring

comment:9 follow-up: Changed 2 years ago by matt (mattab)

codax, do you mind testing the new versions of the modified files and confirm it is working for your encoded strings?

comment:10 in reply to: ↑ 9 Changed 2 years ago by codax

Replying to matt:

codax, do you mind testing the new versions of the modified files and confirm it is working for your encoded strings?

Thanks for the feedback. We have tested things and now it's working fine.

Note: See TracTickets for help on using tickets.