News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

SMF 2.0.15 Message Preview failing on emojis

Started by butch2k, January 19, 2018, 05:57:03 AM

Previous topic - Next topic

butch2k

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.

butch2k

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)


Arantor

Preview from quick reply or preview from full reply? Modified 2.0.15 or not?

butch2k

#3
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

butch2k

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.

Aleksi "Lex" Kilpinen

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:
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Illori

those are smileys not emoji's from your phone.

Aleksi "Lex" Kilpinen

Oh. Right.

😑

Sorry, tried again - Does it here too.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

butch2k

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 ?

live627

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.

shawnb61

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
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Advertisement: