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
This commit is contained in:
Thiemo Kreuz 2021-10-01 08:49:49 +02:00
parent 208398d96b
commit 0e8a08ebca

View file

@ -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 ) {