aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}