Commit 9e626537 authored by twanvl's avatar twanvl

don't add invalid keywords (empty match) to database.

parent 5bf4a7f2
......@@ -170,7 +170,11 @@ void Keyword::prepare(const vector<KeywordParamP>& 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<KeywordP>& 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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment