• Модуль: mail
  • Путь к файлу: ~/bitrix/modules/mail/lib/message.php
  • Класс: BitrixMailMessage
  • Вызов: Message::parse
protected function parse()
{
	if (isset($this->html))
	{
		$html = $this->html;

		$html = str_replace(array("r", "n"), '', $html);
		$html = preg_replace('//is', "n", $html);

		$html = str_ireplace('
', "
n", $html); $html = str_ireplace('

', "

n", $html); $html = preg_replace('//i', "n", $html); $html = str_ireplace('', "n", $html); $html = str_ireplace('', "n", $html); $html = str_ireplace('‘, «n», $html); $html = preg_replace(‘/(ns*)?
)/i’, «n]*>(s*n)?/i’, «n
n», $html); if ($this->type == ‘reply’ and $parts = $this->splitHtml($html)) { list($before, $quote, $after) = $parts; $html = sprintf(‘%s%s%s’, $before, static::QUOTE_PLACEHOLDER, $after); } if ($this->attachmentsCount()) { foreach ($this->attachments as $item) { $html = preg_replace( sprintf(‘/]+srcs*=s*(‘|»)?s*(cid:%s)s*1[^>]*>/is’, preg_quote($item[‘contentId’], ‘/’)), sprintf(‘[ATTACHMENT=%s]’, $item[‘uniqueId’]), $html ); } } // TODO: Sanitizer $html = preg_replace(‘/]*>.*?/is’, », $html); $html = preg_replace(‘/]*>.*?/is’, », $html); $html = preg_replace(‘/]*>.*?/is’, », $html); $html = preg_replace(‘/]*>.*?/is’, », $html); // TODO: Sanitizer $html = preg_replace(‘/]*hrefs*=s*([^'»s>]+)s*[^>]*>/is’, ‘‘, $html); // TODO: TextParser $html = preg_replace(‘/]*>(.*?)/is’, ‘1‘, $html); $html = preg_replace(‘/]*>(.*?)/is’, ‘1‘, $html); $html = preg_replace(‘/]*>(.*?)/is’, ‘1‘, $html); $html = preg_replace(‘/]*>/is’, ‘________________________________________’, $html); $html = preg_replace(‘/]*>(.*?)/is’, ‘1‘, $html); $html = preg_replace(‘/]*>(.*?)/is’, ‘1‘, $html); $html = preg_replace(‘/]*>(.*?)/is’, ‘2‘, $html); $html = preg_replace(‘/]*>(.*?)/is’, ‘
    1
‘, $html); $html = preg_replace(‘/]*>/is’, ‘
  • ‘, $html); $html = preg_replace(‘/]*>/is’, ‘ — ‘, $html); $html = preg_replace(‘/<(sub|sup)[^>]*>(.*?)/is’, ‘(2)’, $html); // TODO: TextParser $html = preg_replace(‘/]*>(.*?)/is’, ‘1‘, $html); $sanitizer = new CBXSanitizer(); //$sanitizer->setLevel(CBXSanitizer::SECURE_LEVEL_MIDDLE); $sanitizer->addTags(array( ‘a’ => array(‘href’), ‘b’ => array(), ‘u’ => array(), ‘s’ => array(), ‘i’ => array(), ‘img’ => array(‘src’), ‘font’ => array(‘color’, ‘size’, ‘face’), ‘ul’ => array(), ‘ol’ => array(), ‘li’ => array(), ‘table’ => array(), ‘tr’ => array(), ‘td’ => array(), ‘th’ => array(), ‘quote’ => array(), ‘br’ => array(), //’big’ => array(), //’small’ => array(), )); $sanitizer->applyDoubleEncode(false); $html = $sanitizer->sanitizeHtml($html); $parser = new CTextParser(); $text = $parser->convertHtmlToBB($html); $text = html_entity_decode($text, ENT_QUOTES | ENT_HTML401, LANG_CHARSET); // TODO: TextParser $text = preg_replace(‘/)[^>]*>/i’, », $text); $text = preg_replace(‘/[tx20]+/’, «x20», $text); } else { $text = $this->text; $text = str_replace(«rn», «n», $text); $text = str_replace(«r», «n», $text); if ($this->type == ‘reply’ and $parts = $this->splitText($text)) { list($before, $quote, $after) = $parts; $text = sprintf(‘%s%s%s’, $before, static::QUOTE_PLACEHOLDER, $after); } if ($this->attachmentsCount()) { foreach ($this->attachments as $item) { $text = str_replace( sprintf(‘[cid:%s]’, $item[‘contentId’]), sprintf(‘[ATTACHMENT=%s]’, $item[‘uniqueId’]), $text ); } } } if ($this->type == ‘reply’ && mb_strpos($text, static::QUOTE_PLACEHOLDER)) { $text = $this->removeReplyHead($text); $text = preg_replace(sprintf(‘/s*%ss*/’, preg_quote(static::QUOTE_PLACEHOLDER, ‘/’)), «nn», $text); } if ($this->type == ‘forward’) $text = $this->removeForwardHead($text); // TODO: TextParser $text = preg_replace(‘/[tr]s*[/tr]/is’, », $text); $text = preg_replace(‘/[table]s*[/table]/is’, », $text); $text = trim($text); $text = preg_replace(‘/(s*n){2,}/’, «nn», $text); if (empty($text) && $this->attachmentsCount() == 1) $text = sprintf(‘[ATTACHMENT=%s]’, $item[‘uniqueId’]); if (!empty($this->secret)) $text = str_replace($this->secret, ‘xxxxxxxx’, $text); return $text; }