![]() |
Help with parse_smileys and HTML entities - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html) +--- Thread: Help with parse_smileys and HTML entities (/thread-11953.html) |
Help with parse_smileys and HTML entities - El Forum - 09-29-2008 [eluser]dmorin[/eluser] Not sure if I'm just being dense or what but I'm not seeing an easy solution to this (I have a feeling I"m just being dense)... I store all user input in the database escaped using xss_clean and htmlentites. Then, when I echo out certain fields, I use the parse_smileys function to generate the image tags. The problem occurs when someone uses an htmlentity character directly before a closed parenthesis such as Quote:("TEST")which I then translate to Quote:("TEST&quotwhich the parse_smileys function then interprets the last two characters to be a wink. It doesn't appear that these forums are affected by this, so can someone help me out? If I parse_smileys before converting to entities, it'll screw up the image tags and if I wait until after, I get smileys in the wrong places. Thanks in advance! Help with parse_smileys and HTML entities - El Forum - 09-29-2008 [eluser]sophistry[/eluser] easy, ![]() Help with parse_smileys and HTML entities - El Forum - 09-30-2008 [eluser]dmorin[/eluser] Ha, I'd love to do this, but I've had many requests for more smileys, not fewer! Anyone with EE experience know how it's done in this forum? Help with parse_smileys and HTML entities - El Forum - 09-30-2008 [eluser]sophistry[/eluser] here's a hack the core way to do it, and just may fit your requirements: EDIT: bah! ::bug:: the forum messed up the PHP code, but the important parts are still showing. the smiley helper is just a silly old str_replace() Code: // ------------------------------------------------------------------------ if you require that smileys be proceeded by a space character, then str_replace() will only find those and not the entities. so, just put a space char in front of $key in the foreach loop: Code: // added spsce char to first param of str_replace() now that i am looking at this, it does seem that smiley helper should know this already! is it a bug? Help with parse_smileys and HTML entities - El Forum - 09-30-2008 [eluser]dmorin[/eluser] Adding a space was my first reaction also, though I was going to do it in the config file which would be a bit more work so I like your solution. I'll have to look through my user input and see if most people include a space first so I'm not breaking any of their conventions. I was going to post this in the bug forum but after seeing that this CI forum software handles this well, I assumed there was a work around. Apparently it's just something in EE and not CI. Anyone from Ellis Labs around that can let us know how it's working here? Help with parse_smileys and HTML entities - El Forum - 09-30-2008 [eluser]sophistry[/eluser] quick test of forum software... space in front of winking smiley ![]() no space in front of winking smiley ![]() letter in front ![]() number in front0 ![]() dash - ![]() underscore _ ![]() dollar $ ![]() if you think it is a bug (or something bug-like that needs fixing) you should post the query to the bug forum... it will get more attention over there. Help with parse_smileys and HTML entities - El Forum - 09-30-2008 [eluser]dmorin[/eluser] ;-) Interesting issue though is that if you add a smiley as the first thing in the comment with no space before it, it is still interpreted correctly, which will not happen if I hack up the parse_smileys function to add a space before the key. Waiting just a bit longer to see if anyone has any other ideas before adding starting a conversation in the bug forum. Help with parse_smileys and HTML entities - El Forum - 09-30-2008 [eluser]sophistry[/eluser] :-P ...which indicates to me that the parser is different in EE and probably uses a "smarter" regex in a preg_replace() function. EDIT: to get around that limitation you could just prepend a space to your string as it goes into the parser and then ltrim it when it comes out... |