From 0fdbaecbc65b097a1ee403830cee73cb45aa29d8 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 19 Sep 2015 18:52:27 +0000 Subject: [PATCH] Export: Add late-escaping to the contents of several nodes to avoid creating invalid XML and XML parse errors. Props westonruter. Fixes #33732. git-svn-id: https://develop.svn.wordpress.org/trunk@34333 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/export.php | 65 +++++++++++++++++--------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/wp-admin/includes/export.php b/src/wp-admin/includes/export.php index 3acd7fdc3e..6d01a2c2f3 100644 --- a/src/wp-admin/includes/export.php +++ b/src/wp-admin/includes/export.php @@ -283,9 +283,9 @@ function export_wp( $args = array() ) { foreach ( $authors as $author ) { echo "\t"; - echo '' . $author->ID . ''; - echo '' . $author->user_login . ''; - echo '' . $author->user_email . ''; + echo '' . intval( $author->ID ) . ''; + echo '' . wxr_cdata( $author->user_login ) . ''; + echo '' . wxr_cdata( $author->user_email ) . ''; echo '' . wxr_cdata( $author->display_name ) . ''; echo '' . wxr_cdata( $author->first_name ) . ''; echo '' . wxr_cdata( $author->last_name ) . ''; @@ -304,7 +304,10 @@ function export_wp( $args = array() ) { return; foreach ( $nav_menus as $menu ) { - echo "\t{$menu->term_id}nav_menu{$menu->slug}"; + echo "\t"; + echo '' . intval( $menu->term_id ) . ''; + echo 'nav_menu'; + echo '' . wxr_cdata( $menu->slug ) . ''; wxr_term_name( $menu ); echo "\n"; } @@ -383,13 +386,13 @@ function export_wp( $args = array() ) { - term_id ?>slug; ?>parent ? $cats[$c->parent]->slug : ''; ?> + term_id ); ?>slug ); ?>parent ? $cats[$c->parent]->slug : '' ); ?> - term_id ?>slug; ?> + term_id ); ?>slug ); ?> - term_id ?>taxonomy; ?>slug; ?>parent ? $terms[$t->parent]->slug : ''; ?> + term_id ); ?>taxonomy ); ?>slug ); ?>parent ? $terms[$t->parent]->slug : '' ); ?> @@ -447,20 +450,20 @@ function export_wp( $args = array() ) { */ echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) ); ?> - ID; ?> - post_date; ?> - post_date_gmt; ?> - comment_status; ?> - ping_status; ?> - post_name; ?> - post_status; ?> - post_parent; ?> - menu_order; ?> - post_type; ?> - post_password; ?> - + ID ); ?> + post_date ); ?> + post_date_gmt ); ?> + comment_status ); ?> + ping_status ); ?> + post_name ); ?> + post_status ); ?> + post_parent ); ?> + menu_order ); ?> + post_type ); ?> + post_password ); ?> + post_type == 'attachment' ) : ?> - ID ); ?> + ID ) ); ?> get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) ); @@ -481,7 +484,7 @@ function export_wp( $args = array() ) { continue; ?> - meta_key; ?> + meta_key ); ?> meta_value ); ?> - comment_ID; ?> + comment_ID ); ?> comment_author ); ?> - comment_author_email; ?> + comment_author_email ); ?> comment_author_url ); ?> - comment_author_IP; ?> - comment_date; ?> - comment_date_gmt; ?> + comment_author_IP ); ?> + comment_date ); ?> + comment_date_gmt ); ?> comment_content ) ?> - comment_approved; ?> - comment_type; ?> - comment_parent; ?> - user_id; ?> + comment_approved ); ?> + comment_type ); ?> + comment_parent ); ?> + user_id ); ?> get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) ); foreach ( $c_meta as $meta ) : /** @@ -521,7 +524,7 @@ function export_wp( $args = array() ) { } ?> - meta_key; ?> + meta_key ); ?> meta_value ); ?>