From 76b9432da758350dc474c1d298ff2c67e1159f08 Mon Sep 17 00:00:00 2001 From: nerix Date: Sat, 12 Jul 2025 22:30:54 +0200 Subject: [PATCH] fix: allow messages of just dots (#6330) --- CHANGELOG.md | 2 +- src/providers/twitch/TwitchChannel.cpp | 3 ++- tests/src/TwitchChannel.cpp | 31 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1031748e..7dd41254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ - Bugfix: Fixed inconsistent spaces in messages when using fractional scaling. (#6231, #6254) - Bugfix: Fixed eventsub message delete notifications not being affected by "Show deletions of single messages". (#6233) - Bugfix: Don't add reply buttons to messages that are invalid reply targets. (#6119) -- Bugfix: Fixed invalid commands from being forwarded to Helix, making it possible for information to leak (e.g. if you typed `/bann username ban reason` it would be seen by others in chat as `username ban reason`). (#6272) +- Bugfix: Fixed invalid commands from being forwarded to Helix, making it possible for information to leak (e.g. if you typed `/bann username ban reason` it would be seen by others in chat as `username ban reason`). (#6272, #6330) - Dev: Mini refactor of Split. (#6148) - Dev: Conan will no longer generate a `CMakeUserPresets.json` file. (#6117) - Dev: Pass `--force-openssl` when installing from CMake in Qt 6.8+. (#6129) diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 7ae56e5f..8fd74ae8 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -66,7 +66,8 @@ namespace detail { bool isUnknownCommand(const QString &text) { static QRegularExpression isUnknownCommand( - R"(^(?:\.|\/)(?!me\s|\s))", QRegularExpression::CaseInsensitiveOption); + R"(^(?:\.(?!\.|$)|\/)(?!me(?:\s|$)|\s))", + QRegularExpression::CaseInsensitiveOption); auto match = isUnknownCommand.match(text); diff --git a/tests/src/TwitchChannel.cpp b/tests/src/TwitchChannel.cpp index c36f6cae..1a403b42 100644 --- a/tests/src/TwitchChannel.cpp +++ b/tests/src/TwitchChannel.cpp @@ -20,6 +20,27 @@ TEST(TwitchChannelDetail_isUnknownCommand, good) ". .hello", "/ .hello", ". /hello", + ".", // this results in an empty message but not in an error (twitchdev/issues#1019) + "/me", + ".me", + "..", + "...", + "....", + "", + "foo", + "a", + "!", + ". .", + ". ..", + ".. ..", + ".. .", + "/ /", + "/ .", + ". /", + ". ./", + ".. /", + ".. me", + ". me", }; // clang-format on @@ -40,6 +61,16 @@ TEST(TwitchChannelDetail_isUnknownCommand, bad) ".badcommand hello", "/@badcommand hello", ".@badcommand hello", + "/bann username ban reason", + "/bann username", + "//", + "./", + "./me", + "./w", + "/.", + "/.me", + "/.w", + "/,me", }; // clang-format on