From db5091eaa16d8a321015016a269de2e5be7b5095 Mon Sep 17 00:00:00 2001 From: Mike Schroder Date: Sat, 20 May 2017 02:23:43 +0000 Subject: [PATCH] Media: Decode HTML entities in `author_name` before sending to JS. In `wp_prepare_attachment_for_js()`: - Normalize behavior when author does not exist by returning '(no author)' for `authorName` in these cases. - Decode HTML entities in `author_name`. - Add tests for both of the above. Props arshidkv12, ocean90, sloisel, mikeschroder. Fixes #39955. Built from https://develop.svn.wordpress.org/trunk@40809 git-svn-id: http://core.svn.wordpress.org/trunk@40667 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 6843c61b21..19eba00a6a 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -3098,7 +3098,11 @@ function wp_prepare_attachment_for_js( $attachment ) { ); $author = new WP_User( $attachment->post_author ); - $response['authorName'] = $author->display_name; + if ( $author->exists() ) { + $response['authorName'] = html_entity_decode( $author->display_name, ENT_QUOTES, get_bloginfo( 'charset' ) ); + } else { + $response['authorName'] = __( '(no author)' ); + } if ( $attachment->post_parent ) { $post_parent = get_post( $attachment->post_parent ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 1ec35c02a9..47a257893a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-beta1-40808'; +$wp_version = '4.8-beta1-40809'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.