Prevent add_shortcode from escaping a tag

Look at the source of the_content():

function the_content($more_link_text = null, $stripteaser = false) {
    $content = get_the_content($more_link_text, $stripteaser);
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    echo $content;
}

As you can see, there is no filter to prevent that. If you really need inline JavaScript in an XML document you have to escape dangerous characters like < or avoid the_content().

Ruin your day with the six years old Ticket #3670 Removing CDATA close tag ( ]]> ) unbalances the CDATA block. 🙂

Leave a Comment