From 40632b784f365a1375c87352bec9f2fbf4f17825 Mon Sep 17 00:00:00 2001 From: Kaldari Date: Mon, 17 Dec 2012 19:48:42 -0800 Subject: [PATCH] Strip out wikitext from edit summaries Change-Id: I2a164da5c7bc23323422e6a527deb2547ed8a08f --- formatters/NotificationFormatter.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/formatters/NotificationFormatter.php b/formatters/NotificationFormatter.php index 9a82ad7ce..035f114db 100644 --- a/formatters/NotificationFormatter.php +++ b/formatters/NotificationFormatter.php @@ -140,6 +140,7 @@ abstract class EchoNotificationFormatter { /** * Formats an edit summary + * TODO: implement parsed option for notifications archive page (where we can use all the html) * * @param $event EchoEvent that the notification is for. * @param $user User to format the notification for. @@ -153,11 +154,17 @@ abstract class EchoNotificationFormatter { $revision = Revision::newFromId( $eventData['revid'] ); if ( $revision ) { $summary = $revision->getComment( Revision::FOR_THIS_USER, $user ); + $summary = FeedItem::stripComment( $summary ); + $summary = trim( htmlspecialchars( $summary ) ); if ( $this->outputFormat === 'html' ) { - $summary = Xml::tags( 'div', array( 'class' => 'mw-echo-summary' ), htmlspecialchars( $summary ) ); + // Convert header titles to proper HTML + $summary = preg_replace( "/\/\*\s(.*)\s\*\//", "→\$1:", $summary ); + $summary = Xml::tags( 'span', array( 'class' => 'comment' ), $summary ); + $summary = Xml::tags( 'div', array( 'class' => 'mw-echo-summary' ), $summary ); } return $summary; } return ''; } + }