0

When I select "Allow only safe HTML" for EE's discussion forum it correctly allows tags for links, images, bold etc but it doesn't seem to allow <ol> or <li>. Is there any way to add these to the list of safe HTML tags for EE?

1

Word of Warning First let me warn you the below technique involved modifying core files, and is not recommended. If you update EE you may overwrite these chnages!

What you want to do is add tags to the EE Typography class. /system/expressionengine/libraries/EE_Typeography.php.

To add UL, OL and LI open this file, look to lines 143 to 165 (ish), you will see sometihng like this :

    /** -------------------------------------
    /**  Allowed tags
    /** -------------------------------------*/

    // Note: The decoding array is associative, allowing more precise mapping

    $this->safe_encode = array('b', 'i', 'em', 'del', 'ins', 'strong', 'pre', 'code', 'blockquote');

    $this->safe_decode = array(
        'b'             => 'b',
        'i'             => 'i',
        'em'            => 'em',
        'del'           => 'del',
        'ins'           => 'ins',
        'strong'        => 'strong',
        'pre'           => 'pre',
        'code'          => 'code',
        'blockquote'    => 'blockquote',
        'quote'         => 'blockquote',
        'QUOTE'         => 'blockquote'
    );

To allow the BB style version, add the tags to the safe_decode array, to allow the html version to be encoded as well add them to the safe_encode array. So to allow both BB and HTML OL's and UL's :

    /** -------------------------------------
    /**  Allowed tags
    /** -------------------------------------*/

    // Note: The decoding array is associative, allowing more precise mapping

    $this->safe_encode = array('b', 'i', 'em', 'del', 'ins', 'strong', 'pre', 'code', 'blockquote', 'ol', 'ul', 'li');

    $this->safe_decode = array(
        'b'             => 'b',
        'i'             => 'i',
        'em'            => 'em',
        'del'           => 'del',
        'ins'           => 'ins',
        'strong'        => 'strong',
        'pre'           => 'pre',
        'code'          => 'code',
        'blockquote'    => 'blockquote',
        'quote'         => 'blockquote',
        'QUOTE'         => 'blockquote',
        'ol'            => 'ol',
        'ul'            => 'ul',
        'li'            => 'li'
    );

Enjoy :) Mark as answer if you accept :D

1
  • Happy to help :)
    – Blatant
    Apr 17 '15 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.