/** * Ensures that the filter follows expected behavior * * @return void */ public function testBasic() { $valuesExpected = array('string' => 'string', '<' => '<', '>' => '>', '\'' => '\'', '"' => '"', '&' => '&'); foreach ($valuesExpected as $input => $output) { $this->assertEquals($output, $this->_filter->filter($input)); } }
/** * Ensures that when ENT_NOQUOTES is set, the filtered value leaves both "double" and 'single' quotes un-altered * * @group ZF-8962 * @return void */ public function testQuoteStyleQuotesEncodeNone() { $input = "A 'single' and " . '"double"'; $result = "A 'single' and " . '"double"'; $this->_filter->setQuoteStyle(ENT_NOQUOTES); $this->assertEquals($result, $this->_filter->filter($input)); }
/** * @group ZF-11344 */ public function testRaisesExceptionIfEncodingMismatchDetectedAndFinalStringIsEmpty() { $string = file_get_contents(dirname(__FILE__) . '/_files/latin-1-dash-only.txt'); // restore_error_handler can emit an E_WARNING; let's ignore that, as // we want to test the returned value // Also, explicit try, so that we don't mess up PHPUnit error handlers set_error_handler(array($this, 'errorHandler'), E_NOTICE | E_WARNING); try { $result = $this->_filter->filter($string); $this->fail('Expected exception from single non-utf-8 character'); } catch (Zend_Filter_Exception $e) { $this->assertTrue($e instanceof Zend_Filter_Exception); } }
public function scriptToData($string, $style = 'input') { $string = trim($string); $objhtmlEntities = new Zend_Filter_HtmlEntities(); if ($style == 'editor') { $string = stripslashes($string); // Old version //$string = $objhtmlEntities->filter($string); } else { $string = str_replace(array("\\'", "\"", "'", '"'), array("'", """, "'", """), $string); $string = str_replace('<', '<', $string); $string = str_replace('>', '>', $string); $string = str_replace('%', '\\%', $string); $string = str_replace('_', '\\_', $string); $string = str_replace('-', '\\-', $string); $string = $objhtmlEntities->filter($string); } return $string; }
/** * @param string $text * * @return string */ protected function getContentTextPlain($text) { /** * @see Conjoon_Filter_QuoteToBlockquote */ require_once 'Conjoon/Filter/QuoteToBlockquote.php'; /** * @see Conjoon_Filter_NormalizeLineFeeds */ require_once 'Conjoon/Filter/NormalizeLineFeeds.php'; /** * @see Conjoon_Filter_PlainToHtml */ require_once 'Conjoon/Filter/PlainToHtml.php'; /** * @see Conjoon_Filter_SignatureStrip */ require_once 'Conjoon/Filter/SignatureStrip.php'; $signatureStripper = new \Conjoon_Filter_SignatureStrip(); $quoteFilter = new \Conjoon_Filter_QuoteToBlockquote(); $lineFeedFilter = new \Conjoon_Filter_NormalizeLineFeeds(); $plainToHtmlFilter = new \Conjoon_Filter_PlainToHtml(); /** * @see \Zend_Filter_HtmlEntities */ require_once 'Zend/Filter/HtmlEntities.php'; $entitiesFilter = new \Zend_Filter_HtmlEntities(array('quotestyle' => ENT_COMPAT, 'charset' => 'UTF-8')); $text = $signatureStripper->filter($lineFeedFilter->filter($entitiesFilter->filter($text))); // if signature stripper returned empty messagem, return the data if (trim($text) == "") { $text = trim($text); return $text; } $startTag = "<blockquote>"; $endTag = "</blockquote>"; return $startTag . $plainToHtmlFilter->filter($quoteFilter->filter($text)) . $endTag; }
/** * A draft can be loaded from the database if an id was supplied * or filled with dummy data if no id was supplied. If no id was supplied, * the user wants to create a new email. In this case, the id defaults to * -1. If the user requests to save the draft later on, the id will be updated * to the value of the auto_increment field of the table. * Along with an id the application will need a folder_id so it can tell whether * an existing view has to be updated if this draft was edited and the folder * is currently visible. * Note, that getDraft will also be executed when the user wants to reply to * an email or forward an email. in this case, the id defaults to the email to * which the user wants to forward/ reply to. * * The method awaits 4 POST parameters: * id - the original message to reply to OR the id of the draft that is being * edited * type - the context the draft is in: can be either "new", "forward", * "reply", "reply_all" or "edit" * name: the name of an recipient to send this email to * address: the address of an recipient to send this email to. If that value is not * empty. id will be set to -1 and type will be set to new. If address equals * to name or if name is left empty, only the address will be used to send the * email to. Address is given presedence in any case */ public function getDraftAction() { if ($this->_helper->conjoonContext()->getCurrentContext() != self::CONTEXT_JSON) { /** * see Conjoon_Controller_Action_InvalidContextException */ require_once 'Conjoon/Controller/Action/InvalidContextException.php'; throw new Conjoon_Controller_Action_InvalidContextException("Invalid context for action, expected \"" . self::CONTEXT_JSON . "\", got \"" . $this->_helper->conjoonContext()->getCurrentContext() . "\""); } $path = $_POST['path']; // check if folder is remote folder /** * @see Conjoon_Text_Parser_Mail_MailboxFolderPathJsonParser */ require_once 'Conjoon/Text/Parser/Mail/MailboxFolderPathJsonParser.php'; $parser = new Conjoon_Text_Parser_Mail_MailboxFolderPathJsonParser(); $pathInfo = $parser->parse($path); /** * @see Conjoon_Modules_Groupware_Email_Folder_Facade */ require_once 'Conjoon/Modules/Groupware/Email/Folder/Facade.php'; $facade = Conjoon_Modules_Groupware_Email_Folder_Facade::getInstance(); if (!empty($pathInfo) && $facade->isRemoteFolder($pathInfo['rootId'])) { return $this->getDraftFromRemoteServer($_POST['id'], $path, $_POST['type']); } /** * @see Conjoon_Keys */ require_once 'Conjoon/Keys.php'; /** * @see Conjoon_BeanContext_Inspector */ require_once 'Conjoon/BeanContext/Inspector.php'; /** * @see Conjoon_Modules_Groupware_Email_Draft_Filter_DraftResponse */ require_once 'Conjoon/Modules/Groupware/Email/Draft/Filter/DraftResponse.php'; /** * @see Conjoon_Modules_Groupware_Email_Account_Model_Account */ require_once 'Conjoon/Modules/Groupware/Email/Account/Model/Account.php'; /** * @see Conjoon_Util_Array */ require_once 'Conjoon/Util/Array.php'; $auth = Zend_Registry::get(Conjoon_Keys::REGISTRY_AUTH_OBJECT); $userId = $auth->getIdentity()->getId(); $id = (int) $_POST['id']; $type = (string) $_POST['type']; $accountModel = new Conjoon_Modules_Groupware_Email_Account_Model_Account(); // create a new draft so that the user is able to write an email from scratch! if ($id <= 0) { /** * @see Conjoon_Modules_Groupware_Email_Draft */ require_once 'Conjoon/Modules/Groupware/Email/Draft.php'; $standardId = $accountModel->getStandardAccountIdForUser($userId); if ($standardId == 0) { $this->view->error = $this->getErrorDto('Error while opening draft', 'Please configure an email account first.', Conjoon_Error::LEVEL_ERROR); $this->view->draft = null; $this->view->success = false; return; } $post = $_POST; Conjoon_Util_Array::apply($post, array('groupwareEmailAccountsId' => $standardId, 'groupwareEmailFoldersId' => -1)); $draftFilter = new Conjoon_Modules_Groupware_Email_Draft_Filter_DraftResponse($post, Conjoon_Modules_Groupware_Email_Draft_Filter_DraftResponse::CONTEXT_NEW); $data = $draftFilter->getProcessedData(); $draft = Conjoon_BeanContext_Inspector::create('Conjoon_Modules_Groupware_Email_Draft', $data); $this->view->success = true; $this->view->error = null; $this->view->draft = $draft->getDto(); $this->view->type = $type; return; } // load an email to edit, to reply or to forward it /** * @see Conjoon_Modules_Groupware_Email_Draft_Model_Draft */ require_once 'Conjoon/Modules/Groupware/Email/Draft/Model/Draft.php'; $draftModel = new Conjoon_Modules_Groupware_Email_Draft_Model_Draft(); $draftData = $draftModel->getDraft($id, $userId, $type); if (empty($draftData)) { $this->view->error = $this->getErrorDto('Error while opening draft', 'Could not find the referenced draft.', Conjoon_Error::LEVEL_ERROR); $this->view->draft = null; $this->view->success = false; return; } switch ($type) { case 'reply': $context = Conjoon_Modules_Groupware_Email_Draft_Filter_DraftResponse::CONTEXT_REPLY; break; case 'reply_all': $context = Conjoon_Modules_Groupware_Email_Draft_Filter_DraftResponse::CONTEXT_REPLY_ALL; break; case 'forward': $context = Conjoon_Modules_Groupware_Email_Draft_Filter_DraftResponse::CONTEXT_FORWARD; break; case 'edit': $context = Conjoon_Modules_Groupware_Email_Draft_Filter_DraftResponse::CONTEXT_EDIT; break; default: throw new Exception("Type {$type} not supported."); break; } Conjoon_Util_Array::camelizeKeys($draftData); $addresses = $accountModel->getEmailAddressesForUser($userId); $draftData['userEmailAddresses'] = $addresses; /** * @ticket CN-708 * if context is not edit and equals to reply* or forward, read out the * "to" address and find the matching account we'll be using for setting as * account from which the mail gets edited */ $matchingAccountId = -1; if ($context !== Conjoon_Modules_Groupware_Email_Draft_Filter_DraftResponse::CONTEXT_EDIT) { $orgTo = $draftData['to']; $matchingAccountId = $this->guessMailAccountForAddress($orgTo); if ($matchingAccountId > -1) { $draftData['groupwareEmailAccountsId'] = $matchingAccountId; } } $draftFilter = new Conjoon_Modules_Groupware_Email_Draft_Filter_DraftResponse($draftData, $context); $data = $draftFilter->getProcessedData(); $templateData = $data; // needed for draft forward because of Bean_Inspector unset($data['userEmailAddresses']); unset($data['from']); unset($data['replyTo']); if ($type == 'forward') { $data['to'] = array(); $data['cc'] = array(); } // convert email addresses /** * @see Conjoon_Modules_Groupware_Email_Address */ require_once 'Conjoon/Modules/Groupware/Email/Address.php'; $to = array(); $cc = array(); $bcc = array(); foreach ($data['to'] as $add) { $to[] = new Conjoon_Modules_Groupware_Email_Address($add); } foreach ($data['cc'] as $add) { $cc[] = new Conjoon_Modules_Groupware_Email_Address($add); } foreach ($data['bcc'] as $add) { $bcc[] = new Conjoon_Modules_Groupware_Email_Address($add); } $data['to'] = $to; $data['cc'] = $cc; $data['bcc'] = $bcc; $draft = Conjoon_BeanContext_Inspector::create('Conjoon_Modules_Groupware_Email_Draft', $data)->getDto(); if ($type == 'forward') { $applicationPath = $this->_helper->registryAccess()->getApplicationPath(); /** * @see Conjoon_Text_PhpTemplate */ require_once 'Conjoon/Text/PhpTemplate.php'; /** * @see Conjoon_Filter_StringWrap */ require_once 'Conjoon/Filter/StringWrap.php'; /** * @see Zend_Filter_HtmlEntities */ require_once 'Zend/Filter/HtmlEntities.php'; $cfsw = new Conjoon_Filter_StringWrap('[Fwd: ', ']'); $zfhe = new Zend_Filter_HtmlEntities(array('quotestyle' => ENT_COMPAT, 'charset' => 'UTF-8')); $draft->subject = $cfsw->filter($templateData['subject']); $templateData['subject'] = $zfhe->filter($templateData['subject']); $phpTemplate = new Conjoon_Text_PhpTemplate(array(Conjoon_Text_PhpTemplate::PATH => $applicationPath . '/templates/groupware/email/message.forward.phtml', Conjoon_Text_PhpTemplate::VARS => $templateData)); $draft->contentTextPlain = $phpTemplate->getParsedTemplate(); } $this->view->success = true; $this->view->error = null; $this->view->draft = $draft; $this->view->type = $type; }
public function setParam($key, $value) { $filter = new Zend_Filter_HtmlEntities(); $this->_params[$key] = $filter->filter($value); }
public function render($content) { $filter = new Zend_Filter_HtmlEntities(); $content = $filter->filter($content); return parent::render($content); }
/** * * @param Conjoon_Modules_Groupware_Email_Account_Dto $accountDto * @param array $pathInfo the pathInfo parts for the remote folder, * which have to be assembled again using the remote storage's delimiter * @param array $sortInfo * * @return array * * @throws Conjoon_Argument_Exception */ protected function _getEmailItemListForAccountAndRemoteFolder(Conjoon_Modules_Groupware_Email_Account_Dto $accountDto, $pathInfo, array $sortInfo = array(), $additionalInfo, $from, $to, $userId) { if (is_array($pathInfo)) { $path = $pathInfo['path']; $rootId = $pathInfo['rootId']; $globalName = $this->_getFolderFacade()->getAssembledGlobalNameForAccountAndPath($accountDto, $path); } else { $globalName = $pathInfo; $fld = $this->_getFolderFacade()->getRootFolderForAccountId($accountDto, $userId); $rootId = $fld[0]->id; /** * @see Conjoon_Modules_Groupware_Email_ImapHelper */ require_once 'Conjoon/Modules/Groupware/Email/ImapHelper.php'; $path = Conjoon_Modules_Groupware_Email_ImapHelper::splitFolderForImapAccount($globalName, $accountDto); } /** * @see Conjoon_Date_Format */ require_once 'Conjoon/Date/Format.php'; /** * @see Conjoon_Modules_Groupware_Email_ImapHelper */ require_once 'Conjoon/Modules/Groupware/Email/ImapHelper.php'; $protocol = Conjoon_Modules_Groupware_Email_ImapHelper::reuseImapProtocolForAccount($accountDto); /** * @see Zend_Mail_Storage_Imap */ require_once 'Conjoon/Mail/Storage/Imap.php'; $storage = new Conjoon_Mail_Storage_Imap($protocol); $messageStruct = $storage->getHeaderListAndMetaInformationForGlobalName($globalName, $from, $to); /** * @see Conjoon_Text_Parser_Mail_MessageHeaderParser */ require_once 'Conjoon/Text/Parser/Mail/MessageHeaderParser.php'; $parser = new Conjoon_Text_Parser_Mail_MessageHeaderParser(); /** * @see Conjoon_Text_Transformer_DateStringSanitizer */ require_once 'Conjoon/Text/Transformer/DateStringSanitizer.php'; $sanitizeDateTransformer = new Conjoon_Text_Transformer_DateStringSanitizer(); /** * @see Conjoon_Text_Transformer_MimeDecoder */ require_once 'Conjoon/Text/Transformer/MimeDecoder.php'; $mimeDecoder = new Conjoon_Text_Transformer_MimeDecoder(); /** * @see Conjoon_Text_Parser_Mail_EmailAddressIdentityParser */ require_once 'Conjoon/Text/Parser/Mail/EmailAddressIdentityParser.php'; $identityParser = new Conjoon_Text_Parser_Mail_EmailAddressIdentityParser(); $identityParserSender = new Conjoon_Text_Parser_Mail_EmailAddressIdentityParser(array('addSlashes' => false, 'useQuoting' => false)); /** * @see Conjoon_Text_Transformer_Mail_EmailAddressNameQuoteTransformer */ require_once 'Conjoon/Text/Transformer/Mail/EmailAddressNameQuoteTransformer.php'; $quoteTransformer = new Conjoon_Text_Transformer_Mail_EmailAddressNameQuoteTransformer(); $parsedHeaders = array(); for ($i = 0, $len = count($messageStruct); $i < $len; $i++) { try { $header = $parser->parse($messageStruct[$i]['header']); } catch (Exception $e) { continue; } $header['date'] = Conjoon_Date_Format::toUtc($sanitizeDateTransformer->transform($header['date'])); // no mime decode needed, already done in EmailHeaderParser $header['subject'] = $mimeDecoder->transform($header['subject']); // RECIPIENTS IS NOT PART OF THE HEADER. $recipients = array_merge(isset($header['to']) ? $identityParser->parse($header['to']) : array(), isset($header['cc']) ? $identityParser->parse($header['cc']) : array(), isset($header['bcc']) ? $identityParser->parse($header['bcc']) : array()); $recipientNames = array(); foreach ($recipients as $address => $addressValue) { if (isset($addressValue[1])) { $recipientNames[] = $quoteTransformer->transform($addressValue[1]); } else { $recipientNames[] = $addressValue[0]; } } $header['recipients'] = $recipientNames; // SENDER IS NOT PART OF THE HEADER. $sender = $identityParserSender->parse($header['from']); $header['sender'] = isset($sender[0][1]) ? $sender[0][1] : $sender[0][0]; // the uid $header['uid'] = $messageStruct[$i]['uid']; $header['isAttachment'] = false; $header['isRead'] = false; $header['isSpam'] = false; $header['referencedAsType'] = array(); // flag processing $flags =& $messageStruct[$i]['flags']; for ($u = 0, $lenu = count($flags); $u < $lenu; $u++) { if ($flags[$u] == '\\Seen') { $header['isRead'] = true; } else { if ($flags[$u] == '$Junk') { $header['isSpam'] = true; } else { if (stripos($flags[$u], 'forwarded') !== false) { array_push($header['referencedAsType'], 'forwarded'); } else { if ($flags[$u] == '\\Answered') { array_push($header['referencedAsType'], 'reply'); } } } } } // possible attachment? $header['isAttachment'] = $this->lookUpImapAttachmentInBodyStructure($messageStruct[$i]['bodystructure']); $parsedHeaders[] = $header; } // PARSED HEADERS IS THE INPUT AS WE NEED IT FOR STORING INTO THE DB // NOW GENERATE THE OUTPUT AS CONJOON EXPECTS IT! /** * @see Conjoon_Date_Format */ require_once 'Conjoon/Date/Format.php'; /** * @see Zend_Filter_HtmlEntities */ require_once 'Zend/Filter/HtmlEntities.php'; $htmlEntitiesFilter = new Zend_Filter_HtmlEntities(array('quotestyle' => ENT_COMPAT)); $responseItems = array(); for ($i = 0, $len = count($parsedHeaders); $i < $len; $i++) { $header =& $parsedHeaders[$i]; $responseItems[] = array('id' => $header['uid'], 'recipients' => $header['recipients'], 'sender' => $header['sender'], 'subject' => $htmlEntitiesFilter->filter($header['subject']), 'date' => Conjoon_Date_Format::utcToLocal($header['date']), 'isRead' => (int) $header['isRead'], 'isAttachment' => (int) $header['isAttachment'], 'isSpam' => (int) $header['isSpam'], 'isDraft' => 0, 'isOutboxPending' => 0, 'referencedAsTypes' => $header['referencedAsType'], 'groupwareEmailFoldersId' => -1, 'path' => array_merge(array($rootId), $path)); } // sort if (isset($sortInfo['sort'])) { switch ($sortInfo['sort']) { case 'date': usort($responseItems, array($this, 'memorySortDate')); break; case 'subject': usort($responseItems, array($this, 'memorySortSubject')); break; case 'recipients': usort($responseItems, array($this, 'memorySortRecipients')); break; case 'sender': usort($responseItems, array($this, 'memorySortSender')); break; case 'is_spam': usort($responseItems, array($this, 'memorySortIsSpam')); break; case 'is_read': usort($responseItems, array($this, 'memorySortIsRead')); break; case 'is_attachment': usort($responseItems, array($this, 'memorySortisAttachment')); break; } if ($sortInfo['dir'] == 'DESC') { $responseItems = array_reverse($responseItems); } } $totalCount = count($responseItems); if (isset($sortInfo['limit']) && isset($sortInfo['start'])) { $responseItems = array_splice($responseItems, $sortInfo['start'], $sortInfo['limit']); } if ($additionalInfo) { return array('items' => $responseItems, 'totalCount' => $totalCount, 'pendingItems' => $this->getPendingCountForGlobalName($accountDto, $globalName)); } return $responseItems; }
/** * @inheritdoc */ public function applyForData(array $data) { try { $this->v('message', $data); $d =& $data['message']; $d['isPlainText'] = 1; $strategyResult = $this->getReadableStrategy()->execute($data); $d['body'] = $strategyResult->getBody(); $d['hasResources'] = false; $d['resourcesLoaded'] = false; if ($strategyResult->hasExternalResources()) { $d['hasResources'] = true; $d['resourcesLoaded'] = $strategyResult->areExternalResourcesLoaded(); } $d['attachments'] = $this->createAttachments($this->v('attachments', $d)); /** * @see \Conjoon_Date_Format */ require_once 'Conjoon/Date/Format.php'; $date = $this->v('date', $d); $date = $date ? $date->format('Y-m-d H:i:s') : null; $d['date'] = \Conjoon_Date_Format::utcToLocal($date); $d['to'] = $this->createAddressList($this->v('to', $d)); $d['cc'] = $this->createAddressList($this->v('cc', $d)); $d['from'] = $this->createAddressList($this->v('from', $d)); $d['bcc'] = $this->createAddressList($this->v('bcc', $d)); $d['replyTo'] = $this->createAddressList($this->v('replyTo', $d)); /** * @see \Zend_Filter_HtmlEntities */ require_once 'Zend/Filter/HtmlEntities.php'; $htmlEntitiesFilter = new \Zend_Filter_HtmlEntities(array('quotestyle' => ENT_COMPAT)); $d['subject'] = $htmlEntitiesFilter->filter($this->v('subject', $d)); unset($d['contentTextPlain']); unset($d['contentTextHtml']); } catch (\Exception $e) { throw new ServicePatronException("Exception thrown by previous exception: " . $e->getMessage(), 0, $e); } return $data; }
/** * The message text to transform can be found in $data['message']['contentTextPlain']. * * @inheritdoc */ public function execute(array $data) { try { ArgumentCheck::check(array('message' => array('type' => 'array', 'allowEmpty' => false)), $data); ArgumentCheck::check(array('contentTextPlain' => array('type' => 'string', 'allowEmpty' => true)), $data['message']); $text = $data['message']['contentTextPlain']; /** * @ticket CN-920 */ if (trim($text) == "") { return new ReadableStrategyResult("", false, false); } /** * @see \Conjoon_Filter_UrlToATag */ require_once 'Conjoon/Filter/UrlToATag.php'; /** * @see \Conjoon_Filter_QuoteToBlockquote */ require_once 'Conjoon/Filter/QuoteToBlockquote.php'; /** * @see \Conjoon_Filter_SignatureWrap */ require_once 'Conjoon/Filter/SignatureWrap.php'; /** * @see \Conjoon_Filter_NormalizeLineFeeds */ require_once 'Conjoon/Filter/NormalizeLineFeeds.php'; /** * @see \Conjoon_Filter_PlainToHtml */ require_once 'Conjoon/Filter/PlainToHtml.php'; /** * @see \Conjoon_Filter_EmoticonReplacement */ require_once 'Conjoon/Filter/EmoticonReplacement.php'; $urlFilter = new \Conjoon_Filter_UrlToATag(array('target' => '_blank')); $quoteFilter = new \Conjoon_Filter_QuoteToBlockquote(); $lineFeedFilter = new \Conjoon_Filter_NormalizeLineFeeds(); $signatureFilter = new \Conjoon_Filter_SignatureWrap('<div class="signature">', '</div>'); $plainToHtmlFilter = new \Conjoon_Filter_PlainToHtml(); $emoticonFilter = new \Conjoon_Filter_EmoticonReplacement(array('O:-)' => '<span class="emoticon innocent"></span>', ':-)' => '<span class="emoticon smile"></span>', ':)' => '<span class="emoticon smile"></span>', ':-D' => '<span class="emoticon laughing"></span>', ':D' => '<span class="emoticon laughing"></span>', ':-(' => '<span class="emoticon frown"></span>', ':(' => '<span class="emoticon frown"></span>', ':-[' => '<span class="emoticon embarassed"></span>', ';-)' => '<span class="emoticon wink"></span>', ';)' => '<span class="emoticon wink"></span>', ':-\\' => '<span class="emoticon undecided"></span>', ':-P' => '<span class="emoticon tongue"></span>', ';-P' => '<span class="emoticon tongue"></span>', ':P' => '<span class="emoticon tongue"></span>', '=-O' => '<span class="emoticon surprise"></span>', ':-*' => '<span class="emoticon kiss"></span>', ':*' => '<span class="emoticon kiss"></span>', '>:o' => '<span class="emoticon yell"></span>', '>:-o' => '<span class="emoticon yell"></span>', '8-)' => '<span class="emoticon cool"></span>', ':-$' => '<span class="emoticon money"></span>', ':-!' => '<span class="emoticon foot"></span>', ':\'(' => '<span class="emoticon cry"></span>', ':-X' => '<span class="emoticon sealed"></span>')); /** * @see \Conjoon_Text_Transformer_Mail_EmailAddressToHtmlTransformer */ require_once 'Conjoon/Text/Transformer/Mail/EmailAddressToHtmlTransformer.php'; $transformer = new \Conjoon_Text_Transformer_Mail_EmailAddressToHtmlTransformer(); /** * @see \Conjoon\Text\Transformer\Html\SanitizeOpeningBracketForLinkTransformer */ require_once 'Conjoon/Text/Transformer/Html/SanitizeOpeningBracketForLinkTransformer.php'; $openingBracketForLinkTransformer = new \Conjoon\Text\Transformer\Html\SanitizeOpeningBracketForLinkTransformer(); /** * @see \Zend_Filter_HtmlEntities */ require_once 'Zend/Filter/HtmlEntities.php'; $zfe = new \Zend_Filter_HtmlEntities(array('quotestyle' => ENT_COMPAT)); return new ReadableStrategyResult($openingBracketForLinkTransformer->transform($transformer->transform($plainToHtmlFilter->filter($signatureFilter->filter($quoteFilter->filter($urlFilter->filter($emoticonFilter->filter($lineFeedFilter->filter($zfe->filter($text))))))))), false, false); } catch (\Exception $e) { /** * @see \Conjoon\Mail\Client\Message\Strategy\StrategyException; */ require_once 'Conjoon/Mail/Client/Message/Strategy/StrategyException.php'; throw new StrategyException("Exception thrown by previous exception", 0, $e); } }
public static function cleanHtml($html) { $chain = new Zend_filter(); $chain->addFilter(new Zend_Filter_StripTags(self::$tags)); $chain->addFilter(new Zend_Filter_StringTrim()); $chain = new Zend_Filter_HtmlEntities(); $html = $chain->filter($html); $html = stripslashes($html); //echo $html; $temp = $html; while (1) { $html = preg_replace('/(<[^>]*)javascript:([^>]*>)/i', '$1$2', $html); //if nothing changed this iteration then break the loop if ($html == $temp) { break; } $temp = $html; } return $html; }