From d7ffa529debb420998c1d2f8c57c61c2f680c4f2 Mon Sep 17 00:00:00 2001 From: Tomasz Mlynski Date: Mon, 13 Aug 2018 15:10:09 +0200 Subject: [PATCH] Recognize DVZ Code Tags syntax on alert intention detection --- inc/plugins/dvz_mentions/parsing.php | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/inc/plugins/dvz_mentions/parsing.php b/inc/plugins/dvz_mentions/parsing.php index bcf7ac7..29ac277 100644 --- a/inc/plugins/dvz_mentions/parsing.php +++ b/inc/plugins/dvz_mentions/parsing.php @@ -14,7 +14,7 @@ function getMatches(string $message, bool $stripIndirectContent = false, int $li $messageContent = $message; if ($stripIndirectContent) { - $messageContent = preg_replace('/\[(quote|code|php)(=[^\]]*)?\](.*?)\[\/\1\]/si', null, $message); + $messageContent = \dvzMentions\Parsing\getMessageWithoutIndirectContent($message); } $lengthRange = \dvzMentions\getSettingValue('min_value_length') . ',' . \dvzMentions\getSettingValue('max_value_length'); @@ -111,3 +111,35 @@ function getUniqueUserSelectorsFromMatches(array $matches): array return $selectors; } + +function getMessageWithoutIndirectContent(string $message) +{ + global $cache; + + // strip default tags + $message = preg_replace('/\[(quote|code|php)(=[^\]]*)?\](.*?)\[\/\1\]/si', null, $message); + + // strip tags with DVZ Code Tags syntax + $pluginsCache = $cache->read('plugins'); + + if (!empty($pluginsCache['active']) && in_array('dvz_code_tags', $pluginsCache['active'])) { + $_blackhole = []; + + if (\dvzCodeTags\getSettingValue('parse_block_fenced_code')) { + $matches = \dvzCodeTags\Parsing\getFencedCodeMatches($message); + $message = \dvzCodeTags\Formatting\getMessageWithPlaceholders($message, $matches, $_blackhole); + } + + if (\dvzCodeTags\getSettingValue('parse_block_mycode_code')) { + $matches = \dvzCodeTags\Parsing\getMycodeCodeMatches($message); + $message = \dvzCodeTags\Formatting\getMessageWithPlaceholders($message, $matches, $_blackhole); + } + + if (\dvzCodeTags\getSettingValue('parse_inline_backticks_code')) { + $matches = \dvzCodeTags\Parsing\getInlineCodeMatches($message); + $message = \dvzCodeTags\Formatting\getMessageWithPlaceholders($message, $matches, $_blackhole); + } + } + + return $message; +}