MyBB Community Forums

Full Version: Corrupt / Unknown character (�) in Last Post's Name
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

I am a relatively new administrator of a local forums project, and I was tasked with upgrading from MyBB 1.8.7 to the newest 1.8.24.

So far, the process was relatively smooth. I now have the forums upgraded and am looking for the little things, that broke / changed between versions. And so far, I have only found one issue, that absolutely eludes me - 

I have modified the forumbit_depth2_lastpost template to show the name of the last thread through the {$lastpost_subject}) variable. It works ~95% of times, but there are cases, where the last thread's name is displayed with the last character replaced with a � sign (Note.: It was a multibyte character - one of the special accented characters my language uses).

First thing that came to mind was an issue with text encoding, but as stated before, 95% of the remaining text on the forums is absolutely okay. The character that broke can even be found elsewhere, on the same page. So, as far as I am aware, this is not an encoding issue.

Next, I checked the database data, if maybe that got corrupted... But no, it also contains the correct thread name, incl. accents. 

Then... I paused and noticed - these corrupt characters only appear in thread names that are too long, and so mybb omits a part of them, and the special character that broke was always the last symbol before the ellipsis (...)

Is it possible that, internally, MyBB treats strings as a sequence of non-decoded bytes and, if the data is too long, simply truncates it to a predefined length, thus, if a multibyte character is present at the end, it can cut away a part of it, corrupting it in the process?

Any help would be much appreciated, thank you!
I found the function that is responsible for doing the trimming. It appears that it uses mbstring if it is exists to parse multibyte characters correctly. If it's missing, it uses the classic, single-byte method which results in the bugs that you may be seeing.

https://github.com/mybb/mybb/blob/featur....php#L5876

Is your server missing the php-mbstring module by chance?
Yes, that was exactly what was missing!

I didn't really have access to the original webhosting's server to check for the available PHP modules, so when MyBB started up, I didn't look for further modules to enable and so I had MBString missing.

Thank you!