Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: Dhayzon on April 12, 2022, 06:38:21 PM

Title: CreatePost 'htmlspecialchars' because it no longer works just like SMF 2.0
Post by: Dhayzon on April 12, 2022, 06:38:21 PM

I used to use in SMF 2.0, works fine

$body = '𝘁𝗲𝘄';
$body = $smcFunc['htmlspecialchars']($body); 
$msgOptions = array( 
            'body' => $body,
            );

createPost($msgOptions, $topicOptions, $posterOptions); 

but in SMF 2.1.1 no longer works, now I returned this

𝘁𝗲𝘄


Title: Re: CreatePost 'htmlspecialchars' because it no longer works just like SMF 2.0
Post by: Arantor on April 12, 2022, 06:49:06 PM
It's working as intended.

Entity 120321 is Unicode 1D601, which is a 4 byte character. The *only* way this goes into a utf8_general_ci table is in Unicode encoding.

If you manually modified your database to be utf8mb4 it won't natively be supported by SMF.

The conversion of 4-byte UTF-8 characters to entity form was introduced in 2.0.10 - I wrote the code for it. The 2.1 behaviour is not new - if it is 'new' that means you weren't encoding the data correctly before inserting it.
Title: Re: CreatePost 'htmlspecialchars' because it no longer works just like SMF 2.0
Post by: Dhayzon on April 12, 2022, 07:33:12 PM
You're right, it was my mistake