Skip to content

Commit 063a74f

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@60520 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8983c6b commit 063a74f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wp-admin/async-upload.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@
142142
$speak_message = sprintf(
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
}
151151

0 commit comments

Comments
 (0)