// it is treated as a simple string by boost::regex.
expr = escape_special_chars(expr);
- boost::regex reg_exp(to_utf8(expr), case_sensitive ?
- boost::regex_constants::normal : boost::regex_constants::icase);
+ boost::regex reg_exp;
+ try {
+ reg_exp.assign(to_utf8(expr), case_sensitive ?
+ boost::regex_constants::normal : boost::regex_constants::icase);
+ } catch (boost::regex_error & e) {
+ // boost::regex throws an exception if the regular expression is not
+ // valid.
+ LYXERR0(Debug::GUI, e.what());
+ return vector<docstring>();
+ }
vector<docstring>::const_iterator it = keys_to_search.begin();
vector<docstring>::const_iterator end = keys_to_search.end();
if (boost::regex_search(data, reg_exp))
foundKeys.push_back(*it);
}
- catch (boost::regex_error &) {
+ catch (boost::regex_error & e) {
+ LYXERR(Debug::GUI, e.what());
return vector<docstring>();
}
}