diff --git a/CHANGELOG.md b/CHANGELOG.md index 328097018fe..3fb0a5b636c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Bugfix: Fixed 7TV usernames messing with Qt's HTML (#5780) - Bugfix: Fixed BTTV emotes occasionally showing the wrong author. (#5783) - Dev: Hard-code Boost 1.86.0 in macos CI builders. (#5774) +- Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784) ## 2.5.2-beta.1 diff --git a/src/controllers/highlights/HighlightPhrase.cpp b/src/controllers/highlights/HighlightPhrase.cpp index 7afd1a33b3c..164de013751 100644 --- a/src/controllers/highlights/HighlightPhrase.cpp +++ b/src/controllers/highlights/HighlightPhrase.cpp @@ -1,11 +1,13 @@ #include "controllers/highlights/HighlightPhrase.hpp" +#include + namespace chatterino { namespace { - const QString REGEX_START_BOUNDARY("(\\b|\\s|^)"); - const QString REGEX_END_BOUNDARY("(\\b|\\s|$)"); + constexpr QStringView REGEX_START_BOUNDARY(u"(?:\\b|\\s|^)"); + constexpr QStringView REGEX_END_BOUNDARY(u"(?:\\b|\\s|$)"); } // namespace @@ -46,7 +48,7 @@ HighlightPhrase::HighlightPhrase(const QString &pattern, bool showInMentions, , soundUrl_(soundUrl) , regex_(isRegex_ ? pattern - : REGEX_START_BOUNDARY + QRegularExpression::escape(pattern) + + : REGEX_START_BOUNDARY % QRegularExpression::escape(pattern) % REGEX_END_BOUNDARY, QRegularExpression::UseUnicodePropertiesOption | (isCaseSensitive_ ? QRegularExpression::NoPatternOption @@ -69,7 +71,7 @@ HighlightPhrase::HighlightPhrase(const QString &pattern, bool showInMentions, , color_(std::move(color)) , regex_(isRegex_ ? pattern - : REGEX_START_BOUNDARY + QRegularExpression::escape(pattern) + + : REGEX_START_BOUNDARY % QRegularExpression::escape(pattern) % REGEX_END_BOUNDARY, QRegularExpression::UseUnicodePropertiesOption | (isCaseSensitive_ ? QRegularExpression::NoPatternOption