miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Bugs miniBB Support Forums / Bugs /  
 

Error: empty, but really not empty message

 
Author Glupstwo
Partaker
#1 | Posted: 5 Nov 2019 11:58 
Some users when want post the message got error that message is short or empty. In true message is not empty or short. Error link to this row on file bb_func_txt.php : foreach($str as $i=>$char){

I found solution and install badwords pluggin. But it not helps.
Please help me to find the problem.

Author Paul
Lead Developer 
#2 | Posted: 5 Nov 2019 12:06 
We need to know a certain exact message to repeat the broblem and then investigate it. If someone from your users gets this problem, please let him/her to send you an exact text which was tried to post, and the error text on the screen they see. Then re-send it to me.

The most important is to repeat the problem. Only then we could investigate and fix it. Pointing to a line of code doesn't help.

Author Glupstwo
Partaker
#3 | Posted: 5 Nov 2019 12:28 
Messages on lithuanian and I don't know ... Users ask me by phone.
I as admin test to post many messages (short, long, in lithuanian letters, only on latin letters...), but got some problem. I found on forum old post (2012, https://www.minibb.com/forums/specific-20/cannot-post-error-message-message-too-short-empty-5896.html ) about french encoding, but then was a php version problem.

Author Glupstwo
Partaker
#4 | Posted: 5 Nov 2019 16:23 
Hi, we solved! Problem appear for lithuanian letters in message and php version on server. When we downground from 7.3 to 7.1, we not got anymore the errors, and our messages was posted. Maybe this problems start from php 7.2. Thanks to Michal from setupad_com team!

Author Paul
Lead Developer 
#5 | Posted: 5 Nov 2019 18:19 
Ok... it really could be something PHP 7.3 specific and it is definitely related to UTF-8 chars. I suppose, the error may appear at the stage when miniBB tries to split a string. At some of my older development stages I've met and worked out this issue, but now it seems to come back.

As it's announced PHP 7.3 release, there were introduced improvements for PCRE extension, MB-string functions and also there are several deprecated features for string-parsing functions. All of these updated could be the reason of this issue.

Alas, I couldn't test UTF-8 texts on PHP 7.3 now, but I will try to do it in the nearest future.

You could try one thing on your own, if you have enough experience... In bb_func_txt.php, miniBB uses this code to split the string by chars, this also includes UTF8-chars:

$str=preg_split($splitExpression, $fragment, null, PREG_SPLIT_NO_EMPTY);
$splitExpression equals to '//u' by default, but this could be re-defined in setup_options.php. I'm not sure what has to be work-out for PHP 7.3, but probably the error comes from this place. When the script tries to split a string, for some reason it couldn't do it and gets an empty value. That's why in result an empty message appears.

Author Paul
Lead Developer 
#6 | Posted: 17 Dec 2019 19:43 
UPDATE: I've been working out the miniBB-based forums which are in cp1251 (windows-1251, or Windows Cyrillic) and discovered that the "strlen_unicode" function currently presented in miniBB 3.4.2 reports a wrong Cyrillic string length. So I've updated this function to something else, and will watch if it works with other encodings. It works on the server where "mb_" functions are not installed, so it uses alternatives to determine the length of the string.

I'd appreciate if you could replace this function and test on your forums, and report if your script still reports an empty message, while it is not empty. Thanks!

(The function is located in bb_functions.php):

function strlen_unicode($str){
$strln=0;
if(strlen($str)!=0) {
if(function_exists('mb_strlen')) {
$detEnc=mb_detect_encoding($str);
if($detEnc=='') $detEnc='auto';
$strln=mb_strlen($str, $detEnc);
}
else {
if (preg_match('/[^\x20-\x7e]/', $str)) {
// this is utf-8
$strln=strlen(utf8_decode($str));
}
else {
// not utf-8 and hopefully a single byte
$strln=strlen($str);
}
}
}
return $strln;
}

Author wiserkow
Guest
#7 | Posted: 26 Feb 2020 00:31 
Paul, the reason of why it might now work - truly hides in this code, really:

$str=preg_split($splitExpression, $fragment, null, PREG_SPLIT_NO_EMPTY);
BUT... if there's a switch to newer PHP versions like 7.3 or 7.4... where UTF-8 defaults for PHP... then whatever you have to put in setup_options.php is:

$splitExpression='//';
Then the UTF-8 fragment is split properly.

Author Paul
Lead Developer 
#8 | Posted: 26 Feb 2020 19:26 
wiserkow
Thank you very much! It's so pretty easy that I believe it should work :) I will put this solution in the Manual later.

Bugs miniBB Support Forums / Bugs /
 Error: empty, but really not empty message
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Get the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑