[wp-trac] [WordPress Trac] #3670: Removing CDATA close tag ( ]]> ) unbalances the CDATA block

WordPress Trac noreply at wordpress.org
Tue Nov 25 08:01:19 UTC 2014


#3670: Removing CDATA close tag ( ]]> ) unbalances the CDATA block
-------------------------------------------------+-------------------------
 Reporter:  scenic                               |       Owner:  andy
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Posts, Post Types                    |  Release
 Severity:  minor                                |     Version:  2.1
 Keywords:  has-patch needs-refresh needs-unit-  |  Resolution:
  tests                                          |     Focuses:  template
-------------------------------------------------+-------------------------

Comment (by awelzel):

 I have to admit that I didn't have time to get into WordPress core coding
 yet - too many other projects - sorry.

 But anyway - until there is a solution - for those who don't want to
 fiddle around with the core code with every update: You can use the
 following workaround in the templates functions.php or a plugin.

 If there is an intentional "]]>" somewhere in a post this ''may'' lead
 to invalid HTML in rare cases - although a "]]>" on its own as part of a
 page or post is not invalid.

 {{{
 function cdata_markupfix($content) {
     $content = str_replace("]]>", "]]>", $content);

     return $content;
 }

 function cdata_template_redirect( $content ) {
         ob_start('cdata_markupfix');
 }

 add_action('template_redirect','cdata_template_redirect',-1);
 }}}

 You can see this live on one of my pages where I embed external scripts
 (using my own plugin) to generate JavaScript stuff and which validates
 fine: http://arnowelzel.de/wp/en/tools/statistics

--
Ticket URL: <https://core.trac.wordpress.org/ticket/3670#comment:72>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list