diff --git a/src/data/keyword.cpp b/src/data/keyword.cpp index 70ba1dcb..9d45d8ae 100644 --- a/src/data/keyword.cpp +++ b/src/data/keyword.cpp @@ -170,7 +170,11 @@ void Keyword::prepare(const vector& param_types, bool force) { } } regex += _(")"); - if (!matchRe.Compile(regex, wxRE_ADVANCED)) { + if (matchRe.Compile(regex, wxRE_ADVANCED)) { + // not valid if it matches "", that would make MSE hang + valid = !matchRe.Matches(_("")); + } else { + valid = false; throw InternalError(_("Error creating match regex")); } } @@ -254,7 +258,7 @@ void KeywordDatabase::add(const vector& kws) { } void KeywordDatabase::add(const Keyword& kw) { - if (kw.match.empty()) return; // can't handle empty keywords + if (kw.match.empty() || !kw.valid) return; // can't handle empty keywords if (!root) { root = new KeywordTrie; root->on_any_star = root; diff --git a/src/data/keyword.hpp b/src/data/keyword.hpp index 5762bacb..04086828 100644 --- a/src/data/keyword.hpp +++ b/src/data/keyword.hpp @@ -65,7 +65,7 @@ class KeywordMode { /// A keyword for a set or a game class Keyword { public: - Keyword() : fixed(false) {} + Keyword() : fixed(false), valid(false) {} String keyword; ///< The keyword, only for human use String rules; ///< Rules/explanation