From 1b39760a3ab3dd88e1412f289392c69aeff99c6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Thu, 29 Oct 2015 14:52:44 -0700 Subject: [PATCH] Revert throwing exceptions on preg_* failures This reverts I3840a56adc0a6e50963b930051892491f8e90245 which threw exceptions on broken UTF-8 in $text. Bug: T115514 Bug: T117066 Change-Id: Ie665056a13f9e3678a49790d787b0a41dbba6362 --- includes/MagicWord.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/includes/MagicWord.php b/includes/MagicWord.php index 17c7cd4914..2c7ba91bf2 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -941,7 +941,6 @@ class MagicWordArray { * * @param string $text * - * @throws Exception * @return array */ public function matchAndRemove( &$text ) { @@ -952,24 +951,13 @@ class MagicWordArray { continue; } $matches = array(); - $matched = preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ); - if ( $matched === false ) { - throw new Exception( __METHOD__ . ': preg_match_all returned false with error code ' - . preg_last_error() ); - } - if ( $matched ) { + if ( preg_match_all( $regex, $text, $matches, PREG_SET_ORDER ) ) { foreach ( $matches as $m ) { list( $name, $param ) = $this->parseMatch( $m ); $found[$name] = $param; } } - $replaced = preg_replace( $regex, '', $text ); - if ( $replaced !== null ) { - $text = $replaced; - } else { - throw new Exception( __METHOD__ . ': preg_replace returned null with error code ' - . preg_last_error() ); - } + $text = preg_replace( $regex, '', $text ); } return $found; } -- 2.20.1