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
This commit is contained in:
Adam Silverstein 2019-06-20 14:14:59 +00:00
parent e9fc71bbbe
commit 0dc3295e29

View File

@ -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, '\\$&' );