aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-07-26 15:37:17 +0000
committerMario <mario@mariovavti.com>2022-07-26 15:37:17 +0000
commite79668ddf43cb66dc9535c521bf990ae42a6e6af (patch)
tree276884859bd6113457e7513db999a7bc1dfb7fbb
parentdc6b6fc35377e077e21d6c43e6a9ffe62301b8f5 (diff)
downloadvolse-hubzilla-e79668ddf43cb66dc9535c521bf990ae42a6e6af.tar.gz
volse-hubzilla-e79668ddf43cb66dc9535c521bf990ae42a6e6af.tar.bz2
volse-hubzilla-e79668ddf43cb66dc9535c521bf990ae42a6e6af.zip
fix lang tests if result is ambigous
-rw-r--r--Zotlabs/Lib/MessageFilter.php36
1 files changed, 26 insertions, 10 deletions
diff --git a/Zotlabs/Lib/MessageFilter.php b/Zotlabs/Lib/MessageFilter.php
index 13ec78072..7d6dcbe8e 100644
--- a/Zotlabs/Lib/MessageFilter.php
+++ b/Zotlabs/Lib/MessageFilter.php
@@ -29,7 +29,19 @@ class MessageFilter {
if (! $word) {
continue;
}
- if (substr($word, 0, 1) === '#' && $tags) {
+ if (isset($lang) && ((strpos($word, 'lang=') === 0) || (strpos($word, 'lang!=') === 0))) {
+ if (!strlen($lang)) {
+ // Result is ambiguous. As we are matching deny rules only at this time, continue tests.
+ // Any matching deny rule concludes testing.
+ continue;
+ }
+ if (strpos($word, 'lang=') === 0 && strcasecmp($lang, trim(substr($word, 5))) == 0) {
+ return false;
+ } elseif (strpos($word, 'lang!=') === 0 && strcasecmp($lang, trim(substr($word, 6))) != 0) {
+ return false;
+ }
+ }
+ elseif (substr($word, 0, 1) === '#' && $tags) {
foreach ($tags as $t) {
if ((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word, 1)) || (substr($word, 1) === '*'))) {
return false;
@@ -51,10 +63,6 @@ class MessageFilter {
}
} elseif ((strpos($word, '/') === 0) && preg_match($word, $text)) {
return false;
- } elseif ((strpos($word, 'lang=') === 0) && ($lang) && (strcasecmp($lang, trim(substr($word, 5))) == 0)) {
- return false;
- } elseif ((strpos($word, 'lang!=') === 0) && ($lang) && (strcasecmp($lang, trim(substr($word, 6))) != 0)) {
- return false;
} elseif (stristr($text, $word) !== false) {
return false;
}
@@ -69,7 +77,19 @@ class MessageFilter {
if (! $word) {
continue;
}
- if (substr($word, 0, 1) === '#' && $tags) {
+ if (isset($lang) && ((strpos($word, 'lang=') === 0) || (strpos($word, 'lang!=') === 0))) {
+ if (!strlen($lang)) {
+ // Result is ambiguous. However we are checking allow rules
+ // and an ambiguous language is always permitted.
+ return true;
+ }
+ if (strpos($word, 'lang=') === 0 && strcasecmp($lang, trim(substr($word, 5))) == 0) {
+ return true;
+ } elseif (strpos($word, 'lang!=') === 0 && strcasecmp($lang, trim(substr($word, 6))) != 0) {
+ return true;
+ }
+ }
+ elseif (substr($word, 0, 1) === '#' && $tags) {
foreach ($tags as $t) {
if ((($t['ttype'] == TERM_HASHTAG) || ($t['ttype'] == TERM_COMMUNITYTAG)) && (($t['term'] === substr($word, 1)) || (substr($word, 1) === '*'))) {
return true;
@@ -91,10 +111,6 @@ class MessageFilter {
}
} elseif ((strpos($word, '/') === 0) && preg_match($word, $text)) {
return true;
- } elseif ((strpos($word, 'lang=') === 0) && ($lang) && (strcasecmp($lang, trim(substr($word, 5))) == 0)) {
- return true;
- } elseif ((strpos($word, 'lang!=') === 0) && ($lang) && (strcasecmp($lang, trim(substr($word, 6))) != 0)) {
- return true;
} elseif (stristr($text, $word) !== false) {
return true;
}