diff --git a/includes/DiscussionParser.php b/includes/DiscussionParser.php index eba108f8a..a1b1ea8a4 100644 --- a/includes/DiscussionParser.php +++ b/includes/DiscussionParser.php @@ -1155,7 +1155,7 @@ abstract class EchoDiscussionParser { static function getTextSnippet( $text, Language $lang, $length = 150, $title = null ) { // Parse wikitext $html = MessageCache::singleton()->parse( $text, $title )->getText(); - $plaintext = self::htmlToText( $html ); + $plaintext = trim( Sanitizer::stripAllTags( $html ) ); return $lang->truncate( $plaintext, $length ); } @@ -1169,18 +1169,10 @@ abstract class EchoDiscussionParser { static function getTextSnippetFromSummary( $text, Language $lang, $length = 150 ) { // Parse wikitext with summary parser $html = Linker::formatLinksInComment( Sanitizer::escapeHtmlAllowEntities( $text ) ); - $plaintext = self::htmlToText( $html ); + $plaintext = trim( Sanitizer::stripAllTags( $html ) ); return $lang->truncate( $plaintext, $length ); } - /** - * @param string $html - * @return string text version of the given html string - */ - public static function htmlToText( $html ) { - return trim( html_entity_decode( strip_tags( $html ), ENT_QUOTES ) ); - } - /** * Extract an edit excerpt from a revision * diff --git a/includes/formatters/EchoPlainTextDigestEmailFormatter.php b/includes/formatters/EchoPlainTextDigestEmailFormatter.php index e6d4b7e42..88d9c5f5c 100644 --- a/includes/formatters/EchoPlainTextDigestEmailFormatter.php +++ b/includes/formatters/EchoPlainTextDigestEmailFormatter.php @@ -21,7 +21,7 @@ class EchoPlainTextDigestEmailFormatter extends EchoEventDigestFormatter { protected function formatModels( array $models ) { $content = []; foreach ( $models as $model ) { - $content[$model->getCategory()][] = EchoDiscussionParser::htmlToText( $model->getHeaderMessage()->parse() ); + $content[$model->getCategory()][] = Sanitizer::stripAllTags( $model->getHeaderMessage()->parse() ); } ksort( $content ); diff --git a/includes/formatters/EchoPlainTextEmailFormatter.php b/includes/formatters/EchoPlainTextEmailFormatter.php index 6e1e03a03..34fdc7d10 100644 --- a/includes/formatters/EchoPlainTextEmailFormatter.php +++ b/includes/formatters/EchoPlainTextEmailFormatter.php @@ -2,15 +2,15 @@ class EchoPlainTextEmailFormatter extends EchoEventFormatter { protected function formatModel( EchoEventPresentationModel $model ) { - $subject = EchoDiscussionParser::htmlToText( $model->getSubjectMessage()->parse() ); + $subject = Sanitizer::stripAllTags( $model->getSubjectMessage()->parse() ); - $text = EchoDiscussionParser::htmlToText( $model->getHeaderMessage()->parse() ); + $text = Sanitizer::stripAllTags( $model->getHeaderMessage()->parse() ); $text .= "\n\n"; $bodyMsg = $model->getBodyMessage(); if ( $bodyMsg ) { - $text .= EchoDiscussionParser::htmlToText( $bodyMsg->parse() ); + $text .= Sanitizer::stripAllTags( $bodyMsg->parse() ); } $primaryLink = $model->getPrimaryLinkWithMarkAsRead();