aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/MessageFilter.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-07-26 15:22:05 +0000
committerMario <mario@mariovavti.com>2022-07-26 15:22:05 +0000
commitdc6b6fc35377e077e21d6c43e6a9ffe62301b8f5 (patch)
treec82f26e3450efd3f587b27b5e6e5f948da51f56d /Zotlabs/Lib/MessageFilter.php
parent199168c318a9e09d3a940e89f824606812265981 (diff)
downloadvolse-hubzilla-dc6b6fc35377e077e21d6c43e6a9ffe62301b8f5.tar.gz
volse-hubzilla-dc6b6fc35377e077e21d6c43e6a9ffe62301b8f5.tar.bz2
volse-hubzilla-dc6b6fc35377e077e21d6c43e6a9ffe62301b8f5.zip
add "falsey" test
Diffstat (limited to 'Zotlabs/Lib/MessageFilter.php')
-rw-r--r--Zotlabs/Lib/MessageFilter.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/Zotlabs/Lib/MessageFilter.php b/Zotlabs/Lib/MessageFilter.php
index 70b0188c4..13ec78072 100644
--- a/Zotlabs/Lib/MessageFilter.php
+++ b/Zotlabs/Lib/MessageFilter.php
@@ -123,7 +123,8 @@ class MessageFilter {
* - ?foo {} baz which will check if 'baz' is an array element in item.foo
* - ?foo {*} baz which will check if 'baz' is an array key in item.foo
* - ?foo which will check for a return of a true condition for item.foo;
- *
+ * - ?!foo which will check for a return of a false condition for item.foo;
+ *
* The values 0, '', an empty array, and an unset value will all evaluate to false.
*
* @param string $s
@@ -205,6 +206,15 @@ class MessageFilter {
return false;
}
+ // Ordering of this check (for falsiness) with relation to the following one (check for truthiness) is important.
+ if (preg_match('/\!(.*?)$/', $s, $matches)) {
+ $x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR);
+ if (!$x) {
+ return true;
+ }
+ return false;
+ }
+
if (preg_match('/(.*?)$/', $s, $matches)) {
$x = ((array_key_exists(trim($matches[1]),$item)) ? $item[trim($matches[1])] : EMPTY_STR);
if ($x) {