1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 22:26:31 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Edward Z. Yang
c552d1141c sfix
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
2024-11-09 21:06:43 -05:00
Edward Z. Yang
caa5a8e830 Exception throwing
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
2024-11-09 21:03:54 -05:00
Edward Z. Yang
7f7ea68432 [fix] Remove occurrences of E_STRICT
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
2024-11-09 20:43:22 -05:00
9 changed files with 17 additions and 17 deletions

View File

@@ -16,7 +16,7 @@ TODO:
*/ */
if (version_compare(PHP_VERSION, '5.2', '<')) exit('PHP 5.2+ required.'); 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 // load dual-libraries
require_once dirname(__FILE__) . '/../extras/HTMLPurifierExtras.auto.php'; require_once dirname(__FILE__) . '/../extras/HTMLPurifierExtras.auto.php';

View File

@@ -77,7 +77,7 @@ class HTMLPurifier_AttrTypes
} }
if (!isset($this->info[$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;
} }
return $this->info[$type]->make($string); return $this->info[$type]->make($string);

View File

@@ -898,8 +898,12 @@ class HTMLPurifier_Config
break; break;
} }
} }
if ($no == E_USER_ERROR) {
throw new Exception($msg . $extra);
} else {
trigger_error($msg . $extra, $no); trigger_error($msg . $extra, $no);
} }
}
/** /**
* Returns a serialized form of the configuration object that can * Returns a serialized form of the configuration object that can

View File

@@ -86,7 +86,7 @@ class HTMLPurifier_DoctypeRegistry
$doctype = $this->aliases[$doctype]; $doctype = $this->aliases[$doctype];
} }
if (!isset($this->doctypes[$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); $anon = new HTMLPurifier_Doctype($doctype);
return $anon; return $anon;
} }

View File

@@ -390,7 +390,7 @@ class HTMLPurifier_Encoder
$str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str); $str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str);
if ($str === false) { if ($str === false) {
// $encoding is not a valid encoding // $encoding is not a valid encoding
trigger_error('Invalid encoding ' . $encoding, E_USER_ERROR); throw new Exception('Invalid encoding ' . $encoding);
return ''; return '';
} }
// If the string is bjorked by Shift_JIS or a similar encoding // If the string is bjorked by Shift_JIS or a similar encoding

View File

@@ -264,9 +264,8 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
if (isset($this->info_content_sets['Block'][$block_wrapper])) { if (isset($this->info_content_sets['Block'][$block_wrapper])) {
$this->info_block_wrapper = $block_wrapper; $this->info_block_wrapper = $block_wrapper;
} else { } else {
trigger_error( throw new Exception(
'Cannot use non-block element as block wrapper', 'Cannot use non-block element as block wrapper'
E_USER_ERROR
); );
} }

View File

@@ -112,9 +112,8 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
return; return;
} }
if (!isset($this->fixesForLevel[$this->defaultLevel])) { if (!isset($this->fixesForLevel[$this->defaultLevel])) {
trigger_error( throw new Exception(
'Default level ' . $this->defaultLevel . ' does not exist', 'Default level ' . $this->defaultLevel . ' does not exist'
E_USER_ERROR
); );
return; return;
} }
@@ -162,8 +161,7 @@ class HTMLPurifier_HTMLModule_Tidy extends HTMLPurifier_HTMLModule
$e->$type = $fix; $e->$type = $fix;
break; break;
default: default:
trigger_error("Fix type $type not supported", E_USER_ERROR); throw new Exception("Fix type $type not supported");
break;
} }
} }
} }

View File

@@ -48,7 +48,7 @@ if ( is_string($GLOBALS['HTMLPurifierTest']['PEAR']) ) {
} }
// after external libraries are loaded, turn on compile time errors // 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 // initialize extra HTML Purifier libraries
require '../extras/HTMLPurifierExtras.auto.php'; require '../extras/HTMLPurifierExtras.auto.php';

View File

@@ -23,9 +23,8 @@
* $test_files) do not have underscores in their names. * $test_files) do not have underscores in their names.
*/ */
// HTML Purifier runs error free on E_STRICT, so if code reports // HTML Purifier runs error free.
// errors, we want to know about it. error_reporting(E_ALL);
error_reporting(E_ALL | E_STRICT);
// Because we always want to know about errors, and because SimpleTest // Because we always want to know about errors, and because SimpleTest
// will notify us about them, logging the errors to stderr is // will notify us about them, logging the errors to stderr is