diff options
author | Mario <mario@mariovavti.com> | 2023-11-09 21:37:28 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-11-09 21:37:28 +0000 |
commit | 1063a67ae26be8fcd251eb8498a70f2163ebb094 (patch) | |
tree | aad43fd19559752c84b51e7355059ad1e192a7e6 /include | |
parent | 602ef883bbca995824fe116f4ba33ab8a731ff0c (diff) | |
download | volse-hubzilla-1063a67ae26be8fcd251eb8498a70f2163ebb094.tar.gz volse-hubzilla-1063a67ae26be8fcd251eb8498a70f2163ebb094.tar.bz2 volse-hubzilla-1063a67ae26be8fcd251eb8498a70f2163ebb094.zip |
a possible fix for issue #1816
Diffstat (limited to 'include')
-rw-r--r-- | include/text.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/include/text.php b/include/text.php index 4088e85e1..27dd94bc5 100644 --- a/include/text.php +++ b/include/text.php @@ -894,6 +894,7 @@ function get_tags($s) { // ignore anything in [style= ] $s = preg_replace('/\[style=(.*?)\]/sm','',$s); + // ignore anything in [color= ], because it may contain color codes which are mistaken for tags $s = preg_replace('/\[color=(.*?)\]/sm','',$s); @@ -3061,7 +3062,10 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $bb_tag = (($xc['xchan_network'] === 'zot6') ? 'zrl' : 'url'); $newtag = '@' . (($exclusive) ? '!' : '') . '[' . $bb_tag . '=' . $profile . ']' . $newname . '[/' . $bb_tag . ']'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + + // Replace tag but make sure to not replace something in the middle of a word + $body = preg_replace('/(?<![a-zA-Z0-9=\/])' . preg_quote($tag, '/') . '/', $newtag, $body); + // $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); // append tag to str_tags if(! stristr($str_tags,$newtag)) { @@ -3104,7 +3108,9 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $channel = App::get_channel(); if($channel) { $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . z_root() . '/channel/' . $channel['channel_address'] . ']' . $newname . '[/zrl]'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + // Replace tag but make sure to not replace something in the middle of a word + $body = preg_replace('/(?<![a-zA-Z0-9=\/])' . preg_quote($tag, '/') . '/', $newtag, $body); + // $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); } } } @@ -3125,7 +3131,9 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) */ if ($termtype === TERM_MENTION) { $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + // Replace tag but make sure to not replace something in the middle of a word + $body = preg_replace('/(?<![a-zA-Z0-9=\/])' . preg_quote($tag, '/') . '/', $newtag, $body); + // $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); } // append tag to str_tags |