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

Migrate AttrValidator to nested error format; modify generator logic in ErrorCollector.

AttrValidator's changes are fairly self-explanatory, but ErrorCollector's
changes are worth a little discussion.  ErrorCollector can use generators at
various points during its flow control; there are two distinct generators that
it should use: 1. The one used for the output, and 2. The one used for the
error output.  These will usually be the same, but in the odd case where they
need to be different, getHTMLFormatted() will accept an alterate configuration
object with an appropriate doctype.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang
2008-08-18 22:13:58 -04:00
parent c807ed5fe2
commit d9e60350d3
3 changed files with 54 additions and 13 deletions

View File

@@ -25,10 +25,9 @@ class HTMLPurifier_ErrorCollector
public function __construct($context) {
$this->locale =& $context->get('Locale');
$this->generator =& $context->get('Generator');
$this->context = $context;
$this->_current =& $this->_stacks[0];
$this->errors =& $this->_stacks[0];
$this->errors =& $this->_stacks[0];
}
/**
@@ -141,6 +140,7 @@ class HTMLPurifier_ErrorCollector
public function getHTMLFormatted($config, $errors = null) {
$ret = array();
$generator = new HTMLPurifier_Generator($config, $this->context);
if ($errors === null) $errors = $this->errors;
// sort error array by line
@@ -161,7 +161,7 @@ class HTMLPurifier_ErrorCollector
list($line, $severity, $msg, $children) = $error;
$string = '';
$string .= '<strong>' . $this->locale->getErrorName($severity) . '</strong>: ';
$string .= $this->generator->escape($msg);
$string .= $generator->escape($msg);
if ($line) {
// have javascript link generation that causes
// textarea to skip to the specified line