Fixed Error-Handling of Regex.class.php
authorTim Düsterhus <timwolla@arcor.de>
Thu, 7 Jun 2012 14:34:01 +0000 (16:34 +0200)
committerTim Düsterhus <timwolla@arcor.de>
Thu, 7 Jun 2012 14:34:01 +0000 (16:34 +0200)
wcfsetup/install/files/lib/system/Regex.class.php

index 848a3245f9b348286c32b3bac37c26c154b770f2..4eae656de449ef986ba0415f86449f01be6475ce 100644 (file)
@@ -6,7 +6,7 @@ use \wcf\system\exception\SystemException;
  * Represents a regex.
  * 
  * @author     Tim Düsterhus
- * @copyright  2011 Tim Düsterhus
+ * @copyright  2011 - 2012 Tim Düsterhus
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system
@@ -181,7 +181,7 @@ final class Regex {
         * @param       mixed   $result
         */
        private function checkResult($result, $method = '') {
-               if ($result === false) {
+               if ($result === false || $result === null) {
                        switch (preg_last_error()) {
                                case PREG_INTERNAL_ERROR:
                                        $error = 'Internal error';
@@ -195,10 +195,12 @@ final class Regex {
                                case PREG_BAD_UTF8_ERROR:
                                        $error = 'Bad UTF8';
                                break;
+                               case PREG_NO_ERROR:
+                                       return $result;
                                default:
                                        $error = 'Unknown error';
                        }
-
+                       
                        throw new SystemException('Could not execute '.($method ? $method.' on ' : '').$this->regex.': '.$error);
                }
                return $result;