• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Smilies and character escaping

Caelum

Well-known member
#1
Ran into an interesting bug just now. Smilies replacing strings of text involving : and \ characters don't work properly. Haven't tested it too thoroughly yet, but does look like an XF bug so far.

To reproduce:
  • Create a new smiley.
  • Enable CSS sprite mode for good measure. I'd imagine it happens without it too, though
  • Make the smiley replace the following text: ':\' (without quotation marks)
  • When posting a thread, select the smiley manually through the smiley chooser. The bug doesn't happen when typing :\ out.
  • The smiley will not appear in the editor, but will appear in your post.
The result in your post will be something along the lines of:
Code:
:\" class=
Using XF 1.1.
 

Caelum

Well-known member
#3
Yeah. Though, mind you, it only happens in combination with a colon. Scratch that, it happens with some other characters too, for instance '=\'.
 

Robbo

Well-known member
#6
It is a programming thing. \ will escape a character to use it differently. Say you want to write out a string "don't" and you are using ' to surround a string. You would get 'don't'... this would be a syntax error because of the second '. When programming to avoid this we escape it. So 'don\'t' would work fine. I am assuming XenForo uses regex to find smilies in the post and \ is also used to escape regex symbols. This can easily be fixed with a function however it might be working like this for a reason and just require a explanation in the ACP so people know.
 

Caelum

Well-known member
#9
This looks like a TinyMCE bug, but I think I've managed to workaround it.
The good news is that as of XF 1.1.1 it works fine on initial posting. The bad news is, the moment you edit a post that has a :\-smiley in it, it breaks again and the bug comes back.
 

Mike

XenForo developer
Staff member
#10
Should be worked around again now by adding this to the XenForo_BbCode_Formatter_Wysiwyg class:
Code:
protected $_smilieTemplate = '<img src="%1$s" class="mceSmilie" alt="%2$s " />';