WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/20/2017 02:23:00 AM (2 years ago)
Author:
mikeschroder
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r40650 r40809  
    30993099
    31003100    $author = new WP_User( $attachment->post_author );
    3101     $response['authorName'] = $author->display_name;
     3101    if ( $author->exists() ) {
     3102        $response['authorName'] = html_entity_decode( $author->display_name, ENT_QUOTES, get_bloginfo( 'charset' ) );
     3103    } else {
     3104        $response['authorName'] = __( '(no author)' );
     3105    }
    31023106
    31033107    if ( $attachment->post_parent ) {
Note: See TracChangeset for help on using the changeset viewer.