Make WordPress Core


Ignore:
Timestamp:
07/29/2025 01:23:27 AM (8 months ago)
Author:
peterwilsoncc
Message:

Media: Modify escaping used for upload image announcements.

Replaces esc_js() with wp_json_encode() for escaping the screen reader announcement when a media upload fails. As the code is within a <script> tag rather than an inline script handler, the esc_js() function would cause special characters to be announced in their HTML encoded form rather than as the character, eg & would be announced as &amp;.

Follow up to [60263].

Props peterwilsoncc, joedolson.
Fixes #63114.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/async-upload.php

    r60263 r60520  
    143143        /* translators: %s: Name of the file that failed to upload. */
    144144        __( '%s has failed to upload.' ),
    145         esc_js( $_FILES['async-upload']['name'] )
     145        $_FILES['async-upload']['name']
    146146    );
    147147
    148     echo "<script>_.delay(function() {wp.a11y.speak('" . esc_js( $speak_message ) . "');}, 1500);jQuery( 'button#{$button_unique_id}' ).on( 'click', function() {jQuery(this).parents('div.media-item').slideUp(200, function(){jQuery(this).remove();wp.a11y.speak( wp.i18n.__( 'Error dismissed.' ) );jQuery( '#plupload-browse-button' ).trigger( 'focus' );})});</script>\n";
     148    echo '<script>_.delay(function() {wp.a11y.speak(' . wp_json_encode( $speak_message ) . ");}, 1500);jQuery( 'button#{$button_unique_id}' ).on( 'click', function() {jQuery(this).parents('div.media-item').slideUp(200, function(){jQuery(this).remove();wp.a11y.speak( wp.i18n.__( 'Error dismissed.' ) );jQuery( '#plupload-browse-button' ).trigger( 'focus' );})});</script>\n";
    149149    exit;
    150150}
Note: See TracChangeset for help on using the changeset viewer.