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.

git-svn-id: https://develop.svn.wordpress.org/trunk@40809 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mike Schroder
2017-05-20 02:23:00 +00:00
parent daab7c996e
commit 2a5f7a8901
2 changed files with 17 additions and 1 deletions
+5 -1
View File
@@ -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 );