Skip to content

Commit 2034440

Browse files
committed
Media, Updates: Avoid parsing selector values as HTML in admin scripts.
`wp.updates.addAdminNotice()`, `wp.media.transition()` and the attachment details frame's `focusNavButton()` pass a caller-supplied selector to `$()`, which parses a value that looks like HTML as markup. Select through `$( document ).find()` so the value is only ever treated as a selector. This follows [64133] and the admin script changes in the same series.
1 parent 998b5e3 commit 2034440

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/js/_enqueues/wp/media/views.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ media.transition = function( selector, sensitivity ) {
5858

5959
if ( $.support.transition ) {
6060
if ( ! (selector instanceof $) ) {
61-
selector = $( selector );
61+
selector = $( document ).find( selector );
6262
}
6363

6464
// Resolve the deferred when the first element finishes animating.

‎src/js/_enqueues/wp/updates.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@
253253
*
254254
*/
255255
wp.updates.addAdminNotice = function( data ) {
256-
var $notice = $( data.selector ),
256+
var $notice = $( document ).find( data.selector ),
257257
$headerEnd = $( '.wp-header-end' ),
258258
$adminNotice;
259259

‎src/js/media/views/frame/edit-attachments.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ EditAttachments = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.EditAtta
268268
* @param {string} which A CSS selector to target the button to focus.
269269
*/
270270
focusNavButton: function( which ) {
271-
$( which ).trigger( 'focus' );
271+
$( document ).find( which ).trigger( 'focus' );
272272
},
273273

274274
getCurrentIndex: function() {

0 commit comments

Comments
 (0)