From 0dc3295e29e3af4e58e37d5757c774d9d9ace048 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Thu, 20 Jun 2019 14:14:59 +0000 Subject: [PATCH] Themes: improve search by trimming search string. Fix an issue where searching installed themes for an empty string resulted in matching all themes. Props afercia, desrosj, hesyifei, evalarumbe. Fixes #39041. git-svn-id: https://develop.svn.wordpress.org/trunk@45557 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/wp/theme.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index 596b097f59..74a90cc609 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -180,6 +180,9 @@ themes.Collection = Backbone.Collection.extend({ // Start with a full collection this.reset( themes.data.themes, { silent: true } ); + // Trim the term + term = term.trim(); + // Escape the term string for RegExp meta characters term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' );