ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Safe HTML Elements Being Encoded

October 03, 2012 10:32am

Subscribe [2]
  • #1 / Oct 03, 2012 10:32am

    Benjamin Kohl

    10 posts

    We ran into the same issue in this thread ( http://ellislab.com/forums/viewthread/150381/ ) when we wanted to add some elements to the safe HTML list.

    The fix for this can be applied around line 615 in the EE_Typography.php file (we have a few hacks in place). Rather than replacing the opening and closing tags at once, split them into two regular expressions so that nested elements of the same type don’t get skipped over. We ran into this issue with nested unordered list elements.

    // $str = preg_replace("#<".$val.">(.+?)</".$val.">#si", "[$val]\\1[/$val]", $str);
    $str = preg_replace("#<".$val.">#si", "[$val]", $str);
    $str = preg_replace("#</".$val.">#si", "[/$val]", $str);
  • #2 / Oct 04, 2012 5:32pm

    Dan Decker

    7338 posts

    Hi Benjamin Kohl,

    Thanks for the solution! I don’t see this reported in the Bug Tracker. Can you give me some details to replicate, or would you like to file the report?

    Cheers,

  • #3 / Oct 05, 2012 9:16am

    Benjamin Kohl

    10 posts

    Hi Dan,

    I’m not really sure this is a bug. This problem only seems to arise when other HTML elements are added to the safe_encode and safe_decode arrays in the EE_Typography class, which is a core hack anyway. Also, we found that the code I provided was only part of the solution because it broke <a> tag parsing which was normally handled by a regular expression that was a few lines below the change we made.

    In the end, we disgarded the hack provided above and added a function to the “allow all html” channel preference logic that stripped tags like script, embed, object, etc. It also removed HTML attributes like onclick, onfocus, onblur, etc. That way, we avoid modifying those existing regular expressions that were dependent upon the order they were being called.

  • #4 / Oct 08, 2012 12:01pm

    Shane Eckert

    7174 posts

    Hey Benjamin,

    Thank you for the update.

    So where are things now? Are you pass this issue?

    Cheers,

  • #5 / Oct 08, 2012 12:30pm

    Benjamin Kohl

    10 posts

    Yes, thanks.

  • #6 / Oct 08, 2012 12:31pm

    Shane Eckert

    7174 posts

    Hey Benjamin,

    Awesome!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases