Make WordPress Core

Changeset 27649


Ignore:
Timestamp:
03/21/2014 09:03:59 PM (12 years ago)
Author:
ocean90
Message:

Themes: Improve RegExp pattern for search.

  • The replacement of spaces is now done globally.
  • The search term is now escaped for RegExp meta characters.

props westonruter for the hint.
fixes #27479.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/theme.js

    r27643 r27649  
    180180        this.reset( themes.data.themes, { silent: true } );
    181181
    182         // The RegExp object to match
    183         //
     182        // Escape the term string for RegExp meta characters
     183        term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' );
     184
    184185        // Consider spaces as word delimiters and match the whole string
    185186        // so matching terms can be combined
    186         term = term.replace( ' ', ')(?=.*' );
     187        term = term.replace( / /g, ')(?=.*' );
    187188        match = new RegExp( '^(?=.*' + term + ').+', 'i' );
    188189
Note: See TracChangeset for help on using the changeset viewer.