From: Matthias Schmidt Date: Tue, 16 Aug 2016 18:16:59 +0000 (+0200) Subject: Fix signature preview X-Git-Tag: 3.0.0_Beta_1~727 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d6184667622354964ff1e83114a57e4e498c6b51;p=GitHub%2FWoltLab%2FWCF.git Fix signature preview --- diff --git a/wcfsetup/install/files/lib/data/bbcode/MessagePreviewAction.class.php b/wcfsetup/install/files/lib/data/bbcode/MessagePreviewAction.class.php index 9b39b683ea..96bd6d2684 100644 --- a/wcfsetup/install/files/lib/data/bbcode/MessagePreviewAction.class.php +++ b/wcfsetup/install/files/lib/data/bbcode/MessagePreviewAction.class.php @@ -21,7 +21,7 @@ class MessagePreviewAction extends BBCodeAction { * @inheritDoc */ protected $allowGuestAccess = ['getMessagePreview']; - + /** * Validates parameters for message preview. */ diff --git a/wcfsetup/install/files/lib/data/user/UserProfileAction.class.php b/wcfsetup/install/files/lib/data/user/UserProfileAction.class.php index 7a9d81f32d..876ddc89c4 100644 --- a/wcfsetup/install/files/lib/data/user/UserProfileAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserProfileAction.class.php @@ -1,16 +1,19 @@ readString('message', true, 'data'); - - if (!isset($this->parameters['options'])) { - throw new UserInputException('options'); - } - - if (isset($this->parameters['options']['enableBBCodes']) && WCF::getSession()->getPermission('user.signature.canUseBBCodes')) { - $disallowedBBCodes = BBCodeParser::getInstance()->validateBBCodes($this->parameters['data']['message'], explode(',', WCF::getSession()->getPermission('user.signature.allowedBBCodes'))); - if (!empty($disallowedBBCodes)) { - throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', [ - 'disallowedBBCodes' => $disallowedBBCodes - ])); - } - } } /** @@ -60,22 +50,25 @@ class UserProfileAction extends UserAction { * @return array */ public function getMessagePreview() { - // get options - $enableBBCodes = isset($this->parameters['options']['enableBBCodes']) ? 1 : 0; - $enableHtml = isset($this->parameters['options']['enableHtml']) ? 1 : 0; - $enableSmilies = isset($this->parameters['options']['enableSmilies']) ? 1 : 0; + $htmlInputProcessor = new HtmlInputProcessor(); + $htmlInputProcessor->process($this->parameters['data']['message'], 'com.woltlab.wcf.user.signature', WCF::getUser()->userID); + + BBCodeHandler::getInstance()->setDisallowedBBCodes(ArrayUtil::trim(explode(',', WCF::getSession()->getPermission('user.signature.disallowedBBCodes')))); + $disallowedBBCodes = $htmlInputProcessor->validate(); + if (!empty($disallowedBBCodes)) { + throw new UserInputException('message', WCF::getLanguage()->getDynamicVariable('wcf.message.error.disallowedBBCodes', [ + 'disallowedBBCodes' => $disallowedBBCodes + ])); + } - // validate permissions for options - if ($enableBBCodes && !WCF::getSession()->getPermission('user.signature.canUseBBCodes')) $enableBBCodes = 0; - if ($enableHtml && !WCF::getSession()->getPermission('user.signature.canUseHtml')) $enableHtml = 0; - if ($enableSmilies && !WCF::getSession()->getPermission('user.signature.canUseSmilies')) $enableSmilies = 0; + MessageEmbeddedObjectManager::getInstance()->registerTemporaryMessage($htmlInputProcessor); - // parse message - $message = StringUtil::trim($this->parameters['data']['message']); - $preview = MessageParser::getInstance()->parse($message, $enableSmilies, $enableHtml, $enableBBCodes, false); + $htmlOutputProcessor = new HtmlOutputProcessor(); + $htmlOutputProcessor->process($htmlInputProcessor->getHtml(), 'com.woltlab.wcf.user.signature', WCF::getUser()->userID); return [ - 'message' => $preview + 'message' => $htmlOutputProcessor->getHtml(), + 'raw' => $htmlInputProcessor->getHtml() ]; }