Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: butch2k on January 19, 2018, 05:57:03 AM

Title: SMF 2.0.15 Message Preview failing on emojis
Post by: butch2k on January 19, 2018, 05:57:03 AM
Just put some emojis like those ones 😛😆 and preview the message using the preview button, it will generate an empty message error.

Just noticed it today so i haven't investigated where the code is failing exactly.
Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: butch2k on January 19, 2018, 06:47:21 AM
I'm pretty sure it's a problem with uriencode/decode not being able correctly decode the emojis which are longer entities than usual.
A single 😛 translate, once uriencoded, in the preview;xml query as: %ED%A0%BD%ED%B8%9B (message field)

Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: Arantor on January 19, 2018, 06:49:14 AM
Preview from quick reply or preview from full reply? Modified 2.0.15 or not?
Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: butch2k on January 19, 2018, 06:53:25 AM
You can test it just here it fails as well as on my very modified forum.

preview in quickreply works fine since once you hit the preview button you are redirected to the full editor with a correctly parsed string. It's the uriencoding when sending the XML which is not working correctly i believe. The message field looks very odd, seems almost (6 bytes vs 4) twice as long as it should.

The tongue emoji posted above should encode to: %f0%9f%98%9b but as far as i can tell it's %ED%A0%BD%ED%B8%9B in the preview;xml message field.

My take would be that String.prototype.php_to8bit is failing to correctly encode 4bytes UTF-8 characters
Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: butch2k on January 20, 2018, 05:47:50 AM
Similar to https://github.com/SimpleMachines/SMF2.1/issues/3448

If fixed it in Post.template.php by replacing

x[x.length] = textFields[i] + \'=\' + document.forms.postmodify[textFields[i]].value.replace(/&#/g, \'&#\').php_to8bit().php_urlencode();
with
x[x.length] = textFields[i] + \'=\' + encodeURIComponent(document.forms.postmodify[textFields[i]].value.replace(/&#/g, \'&#\'));

It's a quick fix for the standard editor (i do not use wysiwyg) and my board is UTF-8 i did not check it's impact on ISO based boards.
Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: Aleksi "Lex" Kilpinen on January 20, 2018, 07:05:13 AM
Quote from: butch2k on January 19, 2018, 06:53:25 AM
You can test it just here it fails as well as on my very modified forum.
Does not to me...

:) ;) :D ;D >:( :( :o 8) ??? ::) :P :-[ :-X :-\ :-* :'( O:) :laugh:
Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: Illori on January 20, 2018, 07:13:19 AM
those are smileys not emoji's from your phone.
Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: Aleksi "Lex" Kilpinen on January 20, 2018, 07:16:45 AM
Oh. Right.

😑

Sorry, tried again - Does it here too.
Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: butch2k on January 20, 2018, 07:28:57 AM
It's the .php_to8bit().php_urlencode() which incorrectly encode the emojis.
btw does any of you know why this sequence was used rather than just encodeURIComponent() ? was it for the ISO encoded forums ?
Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: live627 on January 28, 2018, 04:05:17 AM
Quotewas it for the ISO encoded forums ?
Yes.

php_to8bit() could be modified to be a straight pass-through if utf8 is enabled. It already differentiates between charsets,


My test forum on ISO shows the preview fine but without the emoji.
Title: Re: SMF 2.0.15 Message Preview failing on emojis
Post by: shawnb61 on October 03, 2019, 07:04:21 PM
This was reported a few times & a fix is targeted for 2.0.16 - I am going to close the dupes & keep one open:
https://www.simplemachines.org/community/index.php?topic=569620.0