Sanitizer::normalizeWhitespace warn on preg_replace error
Log a warning with preg_replace error instead of passing null to trim. Bug: T385519 Change-Id: If4ad78168d7899685f4fa1f1d89245c85f0beb0b (cherry picked from commit 270499b6e1f96f402c852843d446a7946589986b)
This commit is contained in:
parent
0da8f5d929
commit
332d1dfd83
1 changed files with 6 additions and 4 deletions
|
|
@ -1136,10 +1136,12 @@ class Sanitizer {
|
|||
}
|
||||
|
||||
private static function normalizeWhitespace( string $text ): string {
|
||||
return trim( preg_replace(
|
||||
'/(?:\r\n|[\x20\x0d\x0a\x09])+/',
|
||||
' ',
|
||||
$text ) );
|
||||
$normalized = preg_replace( '/(?:\r\n|[\x20\x0d\x0a\x09])+/', ' ', $text );
|
||||
if ( $normalized === null ) {
|
||||
wfLogWarning( __METHOD__ . ': Failed to normalize whitespace: ' . preg_last_error() );
|
||||
return "";
|
||||
}
|
||||
return trim( $normalized );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue