diff --git a/configdoc/generate.php b/configdoc/generate.php index e0c4e674..275415af 100644 --- a/configdoc/generate.php +++ b/configdoc/generate.php @@ -16,7 +16,7 @@ */ if (version_compare(PHP_VERSION, '5.2', '<')) exit('PHP 5.2+ required.'); -error_reporting(E_ALL | E_STRICT); +error_reporting(E_ALL); // load dual-libraries require_once dirname(__FILE__) . '/../extras/HTMLPurifierExtras.auto.php'; diff --git a/library/HTMLPurifier/AttrTypes.php b/library/HTMLPurifier/AttrTypes.php index e4429e86..62575ca6 100644 --- a/library/HTMLPurifier/AttrTypes.php +++ b/library/HTMLPurifier/AttrTypes.php @@ -77,7 +77,7 @@ public function get($type) } if (!isset($this->info[$type])) { - trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR); + throw new Exception('Cannot retrieve undefined attribute type ' . $type); return; } return $this->info[$type]->make($string); diff --git a/library/HTMLPurifier/Config.php b/library/HTMLPurifier/Config.php index e6566e80..37470c8c 100644 --- a/library/HTMLPurifier/Config.php +++ b/library/HTMLPurifier/Config.php @@ -898,7 +898,11 @@ protected function triggerError($msg, $no) break; } } - trigger_error($msg . $extra, $no); + if ($no == E_USER_ERROR) { + throw new Exception($msg . $extra); + } else { + trigger_error($msg . $extra, $no); + } } /** diff --git a/library/HTMLPurifier/DoctypeRegistry.php b/library/HTMLPurifier/DoctypeRegistry.php index acc1d64a..9ad7b4b1 100644 --- a/library/HTMLPurifier/DoctypeRegistry.php +++ b/library/HTMLPurifier/DoctypeRegistry.php @@ -86,7 +86,7 @@ public function get($doctype) $doctype = $this->aliases[$doctype]; } if (!isset($this->doctypes[$doctype])) { - trigger_error('Doctype ' . htmlspecialchars($doctype) . ' does not exist', E_USER_ERROR); + throw new Exception('Doctype ' . htmlspecialchars($doctype) . ' does not exist'); $anon = new HTMLPurifier_Doctype($doctype); return $anon; } diff --git a/library/HTMLPurifier/Encoder.php b/library/HTMLPurifier/Encoder.php index d4791cc1..8bfaf41d 100644 --- a/library/HTMLPurifier/Encoder.php +++ b/library/HTMLPurifier/Encoder.php @@ -390,7 +390,7 @@ public static function convertToUTF8($str, $config, $context) $str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str); if ($str === false) { // $encoding is not a valid encoding - trigger_error('Invalid encoding ' . $encoding, E_USER_ERROR); + throw new Exception('Invalid encoding ' . $encoding); return ''; } // If the string is bjorked by Shift_JIS or a similar encoding diff --git a/library/HTMLPurifier/HTMLDefinition.php b/library/HTMLPurifier/HTMLDefinition.php index 9b7b334d..c5a1111a 100644 --- a/library/HTMLPurifier/HTMLDefinition.php +++ b/library/HTMLPurifier/HTMLDefinition.php @@ -264,9 +264,8 @@ protected function setupConfigStuff($config) if (isset($this->info_content_sets['Block'][$block_wrapper])) { $this->info_block_wrapper = $block_wrapper; } else { - trigger_error( - 'Cannot use non-block element as block wrapper', - E_USER_ERROR + throw new Exception( + 'Cannot use non-block element as block wrapper' ); } diff --git a/library/HTMLPurifier/HTMLModule/Tidy.php b/library/HTMLPurifier/HTMLModule/Tidy.php index 76fd93a6..bd926dc2 100644 --- a/library/HTMLPurifier/HTMLModule/Tidy.php +++ b/library/HTMLPurifier/HTMLModule/Tidy.php @@ -112,9 +112,8 @@ public function makeFixesForLevel($fixes) return; } if (!isset($this->fixesForLevel[$this->defaultLevel])) { - trigger_error( - 'Default level ' . $this->defaultLevel . ' does not exist', - E_USER_ERROR + throw new Exception( + 'Default level ' . $this->defaultLevel . ' does not exist' ); return; } @@ -162,8 +161,7 @@ public function populate($fixes) $e->$type = $fix; break; default: - trigger_error("Fix type $type not supported", E_USER_ERROR); - break; + throw new Exception("Fix type $type not supported"); } } } diff --git a/tests/common.php b/tests/common.php index db416ffa..7c914115 100644 --- a/tests/common.php +++ b/tests/common.php @@ -48,7 +48,7 @@ function test_autoload($class) } // after external libraries are loaded, turn on compile time errors -error_reporting(E_ALL | E_STRICT); +error_reporting(E_ALL); // initialize extra HTML Purifier libraries require '../extras/HTMLPurifierExtras.auto.php'; diff --git a/tests/index.php b/tests/index.php index c0ee2491..82f1151c 100644 --- a/tests/index.php +++ b/tests/index.php @@ -23,9 +23,8 @@ * $test_files) do not have underscores in their names. */ -// HTML Purifier runs error free on E_STRICT, so if code reports -// errors, we want to know about it. -error_reporting(E_ALL | E_STRICT); +// HTML Purifier runs error free. +error_reporting(E_ALL); // Because we always want to know about errors, and because SimpleTest // will notify us about them, logging the errors to stderr is