/**
  * @see MessageForm::validateText()
  */
 protected function validateText()
 {
     if (empty($this->text)) {
         return;
     }
     parent::validateText();
     // check image count
     $imageCount = preg_match_all('!\\[img=.+?\\]!i', $this->text, $m) + preg_match_all('!\\[img\\].+?(\\[/img\\]|$)!is', $this->text, $m);
     if ($imageCount > WCF::getUser()->getPermission('user.profile.signature.maxImages')) {
         throw new UserInputException('text', 'tooManyImages');
     }
     if (WCF::getUser()->getPermission('user.profile.signature.maxImageSize') > 0 || WCF::getUser()->getPermission('user.profile.signature.maxImageWidth') > 0 || WCF::getUser()->getPermission('user.profile.signature.maxImageHeight') > 0) {
         // get images
         $images = array();
         // [img=path][/img] syntax
         preg_match_all("!\\[img=(?:'([^'\\\\]+|\\\\.)*'|(.+?))(?:,(?:'(?:left|right)'|(?:left|right)))?\\]!i", $this->text, $matches);
         $images = array_merge($images, ArrayUtil::trim($matches[1]), ArrayUtil::trim($matches[2]));
         // [img]path[/img] syntax
         preg_match_all("!\\[img\\](.+?)(\\[/img\\]|\$)!is", $this->text, $matches);
         $images = array_merge($images, ArrayUtil::trim($matches[1]));
         $errors = array();
         foreach ($images as $image) {
             // download file
             try {
                 if (@($tmpFile = FileUtil::downloadFileFromHttp($image, 'image_'))) {
                     if (WCF::getUser()->getPermission('user.profile.signature.maxImageSize') > 0) {
                         // get remote image size (byte)
                         if (filesize($tmpFile) > WCF::getUser()->getPermission('user.profile.signature.maxImageSize')) {
                             $errors[] = array('errorType' => 'tooLarge', 'image' => $image);
                             continue;
                         }
                     }
                     // get remote image size (pixel)
                     if (WCF::getUser()->getPermission('user.profile.signature.maxImageWidth') > 0 || WCF::getUser()->getPermission('user.profile.signature.maxImageHeight') > 0) {
                         if ($size = @getImageSize($tmpFile)) {
                             $width = $size[0];
                             $height = $size[1];
                             if ($width > WCF::getUser()->getPermission('user.profile.signature.maxImageWidth') || $height > WCF::getUser()->getPermission('user.profile.signature.maxImageHeight')) {
                                 $errors[] = array('errorType' => 'tooLarge', 'image' => $image);
                             }
                         }
                     }
                 }
             } catch (SystemException $e) {
             }
         }
         if (count($errors) > 0) {
             throw new UserInputException('text', $errors);
         }
     }
 }
 /**
  * @see MessageForm::validateText()
  */
 protected function validateText()
 {
     try {
         parent::validateText();
     } catch (UserInputException $e) {
         if ($e->getType() !== 'empty') {
             throw $e;
         }
     }
 }
 /**
  * Validates message text.
  */
 protected function validateText()
 {
     parent::validateText();
     // check text length
     if ($this->minCharLength > 0 && StringUtil::length($this->text) < $this->minCharLength) {
         throw new UserInputException('text', 'tooShort');
     }
     // check word count
     if ($this->minWordCount > 0 && count(preg_split('/[\\W]+/', $this->text, -1, PREG_SPLIT_NO_EMPTY)) < $this->minWordCount) {
         throw new UserInputException('text', 'tooShort');
     }
 }