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

WordPress Trac wp-trac at lists.automattic.com
Wed Jun 13 12:07:15 GMT 2007


#3670: Removing CDATA close tag ( ]]> ) unbalances the CDATA block
----------------------------+-----------------------------------------------
 Reporter:  scenic          |        Owner:  anonymous  
     Type:  defect          |       Status:  new        
 Priority:  low             |    Milestone:  2.3 (trunk)
Component:  Administration  |      Version:  2.1        
 Severity:  normal          |   Resolution:             
 Keywords:  dev-feedback    |  
----------------------------+-----------------------------------------------
Comment (by tellyworth):

 Not sure how helpful this is, but it is kind of possible to nest CDATA
 sections.  Technically I suppose it's double-encoding rather than nesting,
 but regardless, this is 100% valid and should work with any compliant XML
 parser:

 <![CDATA foo <![CDATA bar ]]]><![CDATA[]> baz ]]>

 It's actually two separate CDATA sections concatenated together.

 When decoded by an XML parser, this becomes:

 foo <![CDATA bar ]]> baz

 Here's a PHP snippet to do it:

 return '<![CDATA['.str_replace(']]>', ']]]><![CDATA[]>', $str).']]>';

-- 
Ticket URL: <http://trac.wordpress.org/ticket/3670#comment:11>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list