From 4d0d7760d68ca8db87f105ba0ca67446e77ad4fc Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Fri, 3 Jan 2025 16:41:03 +0100 Subject: [PATCH 1/3] fix: use non-capturing group for highlight boundaries --- src/controllers/highlights/HighlightPhrase.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 From 5eca283cc0204ce111c1c204e8dc464f3a9ed5c0 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Fri, 3 Jan 2025 16:47:48 +0100 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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 From 3dc918c80650fda54193aceb68baad4220372f2b Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 12 Jan 2025 13:30:09 +0100 Subject: [PATCH 3/3] move changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00f926a1cbb..f7fc86957fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Bugfix: Fixed a crash that could occur on Linux and macOS when clicking "Install" from the update prompt. (#5818) - Bugfix: Fixed missing word wrap in update popup. (#5811) - Bugfix: Fixed tabs not scaling to the default scale when changing the scale from a non-default value. (#5794) +- Dev: Highlight checks now use non-capturing groups for the boundaries. (#5784) - Dev: Updated Conan dependencies. (#5776) ## 2.5.2 @@ -22,7 +23,6 @@ - Bugfix: Fixed some Twitch emotes containing HTML entities. (#5786) - Bugfix: Fixed the same blocked term showing up more than once. (#5789) - 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