From 2eb51233f64b21ca552581e3a67d66bf161a6fb5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 12 Dec 2025 19:15:28 +0100 Subject: [PATCH] fix hashtag and mentions count after fixing encoding and add tests --- Zotlabs/Lib/MessageFilter.php | 8 ++++---- tests/unit/Lib/MessageFilterTest.php | 10 ++++++++++ vendor/composer/installed.php | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Zotlabs/Lib/MessageFilter.php b/Zotlabs/Lib/MessageFilter.php index ceb9f83bb..5212f008d 100644 --- a/Zotlabs/Lib/MessageFilter.php +++ b/Zotlabs/Lib/MessageFilter.php @@ -184,8 +184,8 @@ class MessageFilter } } // hashtag count match - if (substr($ruleText, 1, 4) === '>') { - $hashtagLimit = (int)substr($ruleText, 5); + if (substr($ruleText, 1, 1) === '>') { + $hashtagLimit = (int)substr($ruleText, 2); $hashtagCount = 0; foreach ($this->tags as $t) { if ($t['ttype'] == TERM_HASHTAG || $t['ttype'] == TERM_COMMUNITYTAG) { @@ -206,8 +206,8 @@ class MessageFilter } } // mention count match - if (substr($ruleText, 1, 4) === '>') { - $mentionLimit = (int)substr($ruleText, 5); + if (substr($ruleText, 1, 1) === '>') { + $mentionLimit = (int)substr($ruleText, 2); $mentionCount = 0; foreach ($this->tags as $t) { if ($t['ttype'] == TERM_MENTION) { diff --git a/tests/unit/Lib/MessageFilterTest.php b/tests/unit/Lib/MessageFilterTest.php index 630968157..9680dcc69 100644 --- a/tests/unit/Lib/MessageFilterTest.php +++ b/tests/unit/Lib/MessageFilterTest.php @@ -117,6 +117,16 @@ class MessageFilterTest extends UnitTestCase { '#*', false ], + 'max 1 hashtags (we got 3) in excl' => [ + '', + '#>1', + false + ], + 'max 4 hashtags (we got 3) in excl' => [ + '', + '#>4', + true + ], 'item.body contains substring hopper in excl' => [ '', '?body ~= hopper', diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 96f69c4a4..0e9ff3cd2 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'zotlabs/hubzilla', 'pretty_version' => 'dev-10.6RC', 'version' => 'dev-10.6RC', - 'reference' => 'c03f543b54f1ad9d4bb6fc0b08cd5d054764c283', + 'reference' => '5432819788d7e84b919966d6e8e556919f34b892', 'type' => 'application', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -544,7 +544,7 @@ 'zotlabs/hubzilla' => array( 'pretty_version' => 'dev-10.6RC', 'version' => 'dev-10.6RC', - 'reference' => 'c03f543b54f1ad9d4bb6fc0b08cd5d054764c283', + 'reference' => '5432819788d7e84b919966d6e8e556919f34b892', 'type' => 'application', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),