Export valid XML by escaping the closing CDATA sequence "]]>". Props ceefour. See #15203.

git-svn-id: http://svn.automattic.com/wordpress/trunk@19858 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
duck_ 2012-02-07 21:48:45 +00:00
parent c1f604e78e
commit 6f343f700f
1 changed files with 2 additions and 1 deletions

View File

@ -117,13 +117,14 @@ function export_wp( $args = array() ) {
* @since 2.1.0
*
* @param string $str String to wrap in XML CDATA tag.
* @return string
*/
function wxr_cdata( $str ) {
if ( seems_utf8( $str ) == false )
$str = utf8_encode( $str );
// $str = ent2ncr(esc_html($str));
$str = "<![CDATA[$str" . ( ( substr( $str, -1 ) == ']' ) ? ' ' : '' ) . ']]>';
$str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
return $str;
}