1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 13:47:24 +02:00

[1.7.0] Implement line number counting in DirectLex, in preparation for error reporting

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1155 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-06-18 02:01:01 +00:00
parent 70bcccf54c
commit 4bf15de536
6 changed files with 168 additions and 11 deletions

View File

@@ -47,9 +47,24 @@ HTMLPurifier_ConfigSchema::define(
to use it.
</dd>
</dl>
<p>
This directive has been available since 1.7.0.
</p>
'
);
HTMLPurifier_ConfigSchema::define(
'Core', 'MaintainLineNumbers', false, 'bool', '
<p>
If true, HTML Purifier will add line number information to all tokens.
This is useful when error reporting is turned on, but can result in
significant performance degradation and should not be used when
unnecessary. This directive must be used with the DirectLex lexer,
as the DOMLex lexer does not (yet) support this functionality. This directive
has been available since 1.7.0.
</p>
');
/**
* Forgivingly lexes HTML (SGML-style) markup into tokens.
*
@@ -135,7 +150,14 @@ class HTMLPurifier_Lexer
}
if (is_null($lexer)) { do {
// auto-detectection algorithm
// auto-detection algorithm
// once PHP DOM implements native line numbers, or we
// hack out something using XSLT, remove this stipulation
if ($config->get('Core', 'MaintainLineNumbers')) {
$lexer = 'DirectLex';
break;
}
if (version_compare(PHP_VERSION, "5", ">=") && // check for PHP5
class_exists('DOMDocument')) { // check for DOM support