Advertisement:

Author Topic: SMF 2.0.15 Message Preview failing on emojis  (Read 706 times)

Offline butch2k

  • Jr. Member
  • **
  • Posts: 367
  • Gender: Male
    • @butch2k on Twitter
    • Planète Roliste
SMF 2.0.15 Message Preview failing on emojis
« 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.

Offline butch2k

  • Jr. Member
  • **
  • Posts: 367
  • Gender: Male
    • @butch2k on Twitter
    • Planète Roliste
Re: SMF 2.0.15 Message Preview failing on emojis
« Reply #1 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)


Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,361
    • Arantor on GitHub
Re: SMF 2.0.15 Message Preview failing on emojis
« Reply #2 on: January 19, 2018, 06:49:14 AM »
Preview from quick reply or preview from full reply? Modified 2.0.15 or not?
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline butch2k

  • Jr. Member
  • **
  • Posts: 367
  • Gender: Male
    • @butch2k on Twitter
    • Planète Roliste
Re: SMF 2.0.15 Message Preview failing on emojis
« Reply #3 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
« Last Edit: January 19, 2018, 07:07:34 AM by butch2k »

Offline butch2k

  • Jr. Member
  • **
  • Posts: 367
  • Gender: Male
    • @butch2k on Twitter
    • Planète Roliste
Re: SMF 2.0.15 Message Preview failing on emojis
« Reply #4 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

Code: [Select]
x[x.length] = textFields[i] + \'=\' + document.forms.postmodify[textFields[i]].value.replace(/&#/g, \'&#\').php_to8bit().php_urlencode();with
Code: [Select]
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.

Offline Aleksi "Lex" Kilpinen

  • Support Specialist
  • SMF Super Hero
  • *
  • Posts: 16,323
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • aleksi-kilpinen on LinkedIn
Re: SMF 2.0.15 Message Preview failing on emojis
« Reply #5 on: January 20, 2018, 07:05:13 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:
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.

"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

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 48,580
Re: SMF 2.0.15 Message Preview failing on emojis
« Reply #6 on: January 20, 2018, 07:13:19 AM »
those are smileys not emoji's from your phone.

Offline Aleksi "Lex" Kilpinen

  • Support Specialist
  • SMF Super Hero
  • *
  • Posts: 16,323
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • aleksi-kilpinen on LinkedIn
Re: SMF 2.0.15 Message Preview failing on emojis
« Reply #7 on: January 20, 2018, 07:16:45 AM »
Oh. Right.

😑

Sorry, tried again - Does it here too.
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.

"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

Offline butch2k

  • Jr. Member
  • **
  • Posts: 367
  • Gender: Male
    • @butch2k on Twitter
    • Planète Roliste
Re: SMF 2.0.15 Message Preview failing on emojis
« Reply #8 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 ?

Offline live627

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,272
  • Gender: Male
  • Cat: Destroy!
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: SMF 2.0.15 Message Preview failing on emojis
« Reply #9 on: January 28, 2018, 04:05:17 AM »
Quote
was 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.
Try not to become a man of success, but rather try to become a man of value.
- Albert Einstein