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

git-svn-id: https://develop.svn.wordpress.org/trunk@19858 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jon Cave 2012-02-07 21:48:45 +00:00
parent 7cd04da2e6
commit 7efe34d79d
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;
}