From 98488c2c17123e76873f5eb6e76ec6054fdfd57e Mon Sep 17 00:00:00 2001 From: n Date: Sun, 28 Jan 2024 17:23:23 +0100 Subject: [PATCH] do not apply regex replacements if there is no @ character --- clickat.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/clickat.php b/clickat.php index 307bd75..92838e4 100644 --- a/clickat.php +++ b/clickat.php @@ -16,11 +16,10 @@ function hook_clickat_render_linklist($data) '/\ @([\w\d]+)@([\w\d_\-\.]+)/' => ' @\1', '/\ @([\w\d]+)/' => ' @\1' ); - foreach ($data['links'] as &$value) { - foreach($patterns as $nic => $link) { - $value['description'] = preg_replace($nic, $link, $value['description']); - } - } + foreach ($data['links'] as &$value) + if (strpos($value['description'],' @') !== false) + foreach($patterns as $nic => $link) + $value['description'] = preg_replace($nic, $link, $value['description']); return $data; }