diff options
author | Kevin Smith <git@kismith.co.uk> | 2013-06-01 08:26:46 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2013-08-01 09:22:45 (GMT) |
commit | db698bbb6d8c7e878e2cb997e18e572f3646e11d (patch) | |
tree | 61aa3ff72c64dd8f309a2fe4b31b5b2d3f22f04b /Swift/Controllers/HighlightRule.cpp | |
parent | b45602bcd36fb9d2e7a22998434e31014f072d33 (diff) | |
download | swift-contrib-db698bbb6d8c7e878e2cb997e18e572f3646e11d.zip swift-contrib-db698bbb6d8c7e878e2cb997e18e572f3646e11d.tar.bz2 |
Refactor chat messages so parsing of links/emoticons happens in controllers.
Change-Id: I07256f23ffbb6520f5063bdfbed9111946c46746
Diffstat (limited to 'Swift/Controllers/HighlightRule.cpp')
-rw-r--r-- | Swift/Controllers/HighlightRule.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/Swift/Controllers/HighlightRule.cpp b/Swift/Controllers/HighlightRule.cpp index 28f26cf..9ca7d86 100644 --- a/Swift/Controllers/HighlightRule.cpp +++ b/Swift/Controllers/HighlightRule.cpp @@ -9,6 +9,7 @@ #include <boost/lambda/lambda.hpp> #include <Swiften/Base/foreach.h> +#include <Swiften/Base/Regex.h> #include <Swift/Controllers/HighlightRule.h> namespace Swift { @@ -24,16 +25,7 @@ HighlightRule::HighlightRule() boost::regex HighlightRule::regexFromString(const std::string & s) const { - // escape regex special characters: ^.$| etc - // these need to be escaped: [\^\$\|.........] - // and then C++ requires '\' to be escaped, too.... - static const boost::regex esc("([\\^\\.\\$\\|\\(\\)\\[\\]\\*\\+\\?\\/\\{\\}\\\\])"); - // matched character should be prepended with '\' - // replace matched special character with \\\1 - // and escape once more for C++ rules... - static const std::string rep("\\\\\\1"); - std::string escaped = boost::regex_replace(s , esc, rep); - + std::string escaped = Regex::escape(s); std::string word = matchWholeWords_ ? "\\b" : ""; boost::regex::flag_type flags = boost::regex::normal; if (!matchCase_) { |