From 0e8a08ebca28d8a5a5e68bf5f3a6d52e32e0f355 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Fri, 1 Oct 2021 08:49:49 +0200 Subject: [PATCH] Replace custom regex with TextContent::normalizeLineEndings() This does the same as before, replacing \r\n as well as \r with \n. Additionally the new method applies an rtrim() on both strings. I believe this is even a good thing. It possibly removes irrelevant noise from the diff. Change-Id: I584740a24e6b25bbcbc928c2369f09b785a485c8 --- includes/View/AbuseFilterViewDiff.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/View/AbuseFilterViewDiff.php b/includes/View/AbuseFilterViewDiff.php index bfe09ecb9..f7cdd7172 100644 --- a/includes/View/AbuseFilterViewDiff.php +++ b/includes/View/AbuseFilterViewDiff.php @@ -16,6 +16,7 @@ use MediaWiki\Extension\AbuseFilter\SpecsFormatter; use MediaWiki\Extension\AbuseFilter\TableDiffFormatterFullContext; use MediaWiki\Linker\LinkRenderer; use OOUI; +use TextContent; use Xml; class AbuseFilterViewDiff extends AbuseFilterView { @@ -336,10 +337,10 @@ class AbuseFilterViewDiff extends AbuseFilterView { */ public function getDiffRow( $msg, $old, $new ) { if ( !is_array( $old ) ) { - $old = explode( "\n", preg_replace( "/\\\r\\\n?/", "\n", $old ) ); + $old = explode( "\n", TextContent::normalizeLineEndings( $old ) ); } if ( !is_array( $new ) ) { - $new = explode( "\n", preg_replace( "/\\\r\\\n?/", "\n", $new ) ); + $new = explode( "\n", TextContent::normalizeLineEndings( $new ) ); } if ( $old === $new ) {