From f8439040815b5ab34fc3525a3937073430af4114 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 18 Aug 2023 16:58:07 +0200 Subject: [PATCH] Fix the handling of mentions with and without leading @ --- com.woltlab.wcf/templates/userBBCodeTag.tpl | 2 +- wcfsetup/install/files/acp/templates/userBBCodeTag.tpl | 2 +- wcfsetup/install/files/lib/system/bbcode/UserBBCode.class.php | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/com.woltlab.wcf/templates/userBBCodeTag.tpl b/com.woltlab.wcf/templates/userBBCodeTag.tpl index dbe32b29d2..369371df25 100644 --- a/com.woltlab.wcf/templates/userBBCodeTag.tpl +++ b/com.woltlab.wcf/templates/userBBCodeTag.tpl @@ -1,6 +1,6 @@ {if $userProfile === null} {* user no longer exists, use plain output rather than using a broken link *} - @{$username}{* no newline after the tag + {$username}{* no newline after the tag *}{else} {@$userProfile->getFormattedUsername()}{* no newline after the tag *}{/if} diff --git a/wcfsetup/install/files/acp/templates/userBBCodeTag.tpl b/wcfsetup/install/files/acp/templates/userBBCodeTag.tpl index dbe32b29d2..369371df25 100644 --- a/wcfsetup/install/files/acp/templates/userBBCodeTag.tpl +++ b/wcfsetup/install/files/acp/templates/userBBCodeTag.tpl @@ -1,6 +1,6 @@ {if $userProfile === null} {* user no longer exists, use plain output rather than using a broken link *} - @{$username}{* no newline after the tag + {$username}{* no newline after the tag *}{else} {@$userProfile->getFormattedUsername()}{* no newline after the tag *}{/if} diff --git a/wcfsetup/install/files/lib/system/bbcode/UserBBCode.class.php b/wcfsetup/install/files/lib/system/bbcode/UserBBCode.class.php index d96c4b5d2e..0b0d4c290b 100644 --- a/wcfsetup/install/files/lib/system/bbcode/UserBBCode.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/UserBBCode.class.php @@ -21,6 +21,10 @@ final class UserBBCode extends AbstractBBCode */ public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser): string { + if (!\str_starts_with($content, "@")) { + $content = "@{$content}"; + } + $userID = (!empty($openingTag['attributes'][0])) ? \intval($openingTag['attributes'][0]) : 0; if (!$userID) { return "[user]{$content}[/user]"; -- 2.20.1