Merge "Sanitizer::normalizeSectionNameWhitespace: Apply same anti-null fix as 270499b" into REL1_43

This commit is contained in:
jenkins-bot 2025-03-17 16:39:48 +00:00 committed by Gerrit Code Review
commit f6686ed028

View file

@ -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 );
}
/**