From 62ea7e970aeee2b69d2e60a42a9d8a6f6db02da5 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 20 Mar 2019 07:12:48 -0400 Subject: [PATCH] Don't use RegExp for tag filter (Reactification regression) Using a regexp meant that an invalid regexp pattern would crash the tag selector, and even if we caught that it would produce unexpected results for some searches (e.g., anything with a period). --- chrome/content/zotero/containers/tagSelector.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/containers/tagSelector.jsx b/chrome/content/zotero/containers/tagSelector.jsx index 8ca27ef848..420ceed81a 100644 --- a/chrome/content/zotero/containers/tagSelector.jsx +++ b/chrome/content/zotero/containers/tagSelector.jsx @@ -170,7 +170,8 @@ Zotero.TagSelector = class TagSelectorContainer extends React.Component { tags = Array.from(new Set(tags.map(t => t.tag))); } if (this.state.searchString) { - tags = tags.filter(tag => !!tag.match(new RegExp(this.state.searchString, 'i'))); + let lcStr = this.state.searchString.toLowerCase(); + tags = tags.filter(tag => tag.toLowerCase().startsWith(lcStr)); } tags = tags.map((name) => { return {