regex filter: if string is invalid utf-8, ignore it
This commit is contained in:
@@ -56,6 +56,7 @@ inline Regex make(StringT &&s, boost::regex_constants::syntax_option_type flags)
|
|||||||
template <typename StringT>
|
template <typename StringT>
|
||||||
inline bool search(StringT &&s, const Regex &rx)
|
inline bool search(StringT &&s, const Regex &rx)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
return
|
return
|
||||||
# ifdef BOOST_REGEX_ICU
|
# ifdef BOOST_REGEX_ICU
|
||||||
boost::u32regex_search
|
boost::u32regex_search
|
||||||
@@ -63,6 +64,10 @@ inline bool search(StringT &&s, const Regex &rx)
|
|||||||
boost::regex_search
|
boost::regex_search
|
||||||
# endif // BOOST_REGEX_ICU
|
# endif // BOOST_REGEX_ICU
|
||||||
(std::forward<StringT>(s), rx);
|
(std::forward<StringT>(s), rx);
|
||||||
|
} catch (std::out_of_range &) {
|
||||||
|
// Invalid UTF-8 sequence, ignore the string.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
Reference in New Issue
Block a user