diff --git a/includes/parser/Sanitizer.php b/includes/parser/Sanitizer.php index 0f296947ae4..5aaa1984df6 100644 --- a/includes/parser/Sanitizer.php +++ b/includes/parser/Sanitizer.php @@ -1139,7 +1139,7 @@ class Sanitizer { $normalized = preg_replace( '/(?:\r\n|[\x20\x0d\x0a\x09])+/', ' ', $text ); if ( $normalized === null ) { wfLogWarning( __METHOD__ . ': Failed to normalize whitespace: ' . preg_last_error() ); - return ""; + return ''; } return trim( $normalized ); } @@ -1150,7 +1150,12 @@ class Sanitizer { * section links. */ public static function normalizeSectionNameWhitespace( string $section ): string { - return trim( preg_replace( '/[ _]+/', ' ', $section ) ); + $normalized = preg_replace( '/[ _]+/', ' ', $section ); + if ( $normalized === null ) { + wfLogWarning( __METHOD__ . ': Failed to normalize whitespace: ' . preg_last_error() ); + return ''; + } + return trim( $normalized ); } /**