diff --git a/library/HTMLPurifier/AttrValidator.php b/library/HTMLPurifier/AttrValidator.php index 9d692513..9e1e8521 100644 --- a/library/HTMLPurifier/AttrValidator.php +++ b/library/HTMLPurifier/AttrValidator.php @@ -49,22 +49,18 @@ class HTMLPurifier_AttrValidator // do global transformations (pre) // nothing currently utilizes this foreach ($definition->info_attr_transform_pre as $transform) { - if ($e) $e->start(); $attr = $transform->transform($o = $attr, $config, $context); if ($e) { - if ($attr != $o) $e->end(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); - else $e->end(); + if ($attr != $o) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); } } // do local transformations only applicable to this element (pre) // ex.
to
foreach ($definition->info[$token->name]->attr_transform_pre as $transform) { - if ($e) $e->start(); $attr = $transform->transform($o = $attr, $config, $context); if ($e) { - if ($attr != $o) $e->end(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); - else $e->end(); + if ($attr != $o) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); } } @@ -80,7 +76,6 @@ class HTMLPurifier_AttrValidator // Watch out for name collisions: $key has previously been used foreach ($attr as $attr_key => $value) { - if ($e) $e->start(); // call the definition if ( isset($defs[$attr_key]) ) { // there is a local definition defined @@ -112,7 +107,7 @@ class HTMLPurifier_AttrValidator if ($result === false || $result === null) { // this is a generic error message that should replaced // with more specific ones when possible - if ($e) $e->end(E_ERROR, 'AttrValidator: Attribute removed'); + if ($e) $e->send(E_ERROR, 'AttrValidator: Attribute removed'); // remove the attribute unset($attr[$attr_key]); @@ -123,9 +118,8 @@ class HTMLPurifier_AttrValidator // simple substitution $attr[$attr_key] = $result; - if ($e) $e->end(); } else { - if ($e) $e->end(); + // nothing happens } // we'd also want slightly more complicated substitution @@ -141,21 +135,17 @@ class HTMLPurifier_AttrValidator // global (error reporting untested) foreach ($definition->info_attr_transform_post as $transform) { - if ($e) $e->start(); $attr = $transform->transform($o = $attr, $config, $context); if ($e) { - if ($attr != $o) $e->end(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); - else $e->end(); + if ($attr != $o) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); } } // local (error reporting untested) foreach ($definition->info[$token->name]->attr_transform_post as $transform) { - if ($e) $e->start(); $attr = $transform->transform($o = $attr, $config, $context); if ($e) { - if ($attr != $o) $e->end(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); - else $e->end(); + if ($attr != $o) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); } } diff --git a/library/HTMLPurifier/ErrorCollector.php b/library/HTMLPurifier/ErrorCollector.php index 9d101e42..3e7a6eed 100644 --- a/library/HTMLPurifier/ErrorCollector.php +++ b/library/HTMLPurifier/ErrorCollector.php @@ -77,51 +77,6 @@ class HTMLPurifier_ErrorCollector ); } - /** - * Begins the collection of a number of sub-errors. This is useful if you - * are entering a function that may generate errors, but you are able - * to detect the overall state afterwards. - */ - public function start() { - $this->_stacks[] = array(); - $this->_resetCurrent(); - } - - /** - * Terminates the collection of sub-errors, interface is otherwise identical - * to send(). Any sub-errors will be registered as children (3) to this - * error. - * - * @param $severity int Error severity - * @param $msg string Error message text - * @param $subst1 string First substitution for $msg - * @param $subst2 string ... - * - * @note If end() is called with no parameters, it is quiet unless there - * were sub-errors. - */ - public function end() { - $stack = array_pop($this->_stacks); - $this->_resetCurrent(); - $args = func_get_args(); - if ($args) { - call_user_func_array(array($this, 'send'), $args); - } elseif ($stack) { - $this->send(E_NOTICE, 'ErrorCollector: Incidental errors'); - } - if ($stack) { - $this->_current[count($this->_current) - 1][3] = $stack; - } - } - - /** - * Resets the _current member variable to the top of the stacks; i.e. - * the active set of errors being collected. - */ - protected function _resetCurrent() { - $this->_current =& $this->_stacks[count($this->_stacks) - 1]; - } - /** * Retrieves raw error data for custom formatter to use * @param List of arrays in format of array(line of error, diff --git a/tests/HTMLPurifier/ErrorCollectorTest.php b/tests/HTMLPurifier/ErrorCollectorTest.php index 0bc3fe45..977a9758 100644 --- a/tests/HTMLPurifier/ErrorCollectorTest.php +++ b/tests/HTMLPurifier/ErrorCollectorTest.php @@ -112,6 +112,7 @@ class HTMLPurifier_ErrorCollectorTest extends HTMLPurifier_Harness } + /* function testNestedErrors() { $this->language->setReturnValue('getMessage', 'Message 1', array('message-1')); $this->language->setReturnValue('getMessage', 'Message 2', array('message-2')); @@ -142,38 +143,7 @@ class HTMLPurifier_ErrorCollectorTest extends HTMLPurifier_Harness $this->assertIdentical($formatted_result, $formatted_expect); } - - function testNestedErrorsQuiet() { - - $this->language->setReturnValue('getMessage', 'Incidental errors', array('ErrorCollector: Incidental errors')); - $this->language->setReturnValue('getMessage', 'Message', array('message')); - $this->language->setReturnValue('formatMessage', ' at line 4', array('ErrorCollector: At line', array('line' => 4))); - - $this->line = 4; - $this->collector->start(); - $this->collector->send(E_WARNING, 'message'); - $this->collector->end(); - - $expect = array( - 0 => array(4, E_NOTICE, 'Incidental errors', array( - 0 => array(4, E_WARNING, 'Message', array()), - )), - ); - $result = $this->collector->getRaw(); - $this->assertIdentical($result, $expect); - - } - - function testNestedErrorsReallyQuiet() { - - $this->collector->start(); - $this->collector->end(); - - $expect = array(); - $result = $this->collector->getRaw(); - $this->assertIdentical($result, $expect); - - } + */ }