mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-25 00:05:29 +00:00
Merge "Replace EchoDiscussionParser::htmlToText with Sanitizer::stripAllTags()"
This commit is contained in:
commit
fa37dac615
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue