0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-09-19 10:45:18 +00:00

Detect if domxml extension is loaded, and use DirectLex accordingly.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang 2008-10-08 17:06:10 -04:00
parent f7bc0b0875
commit d304c5c976
3 changed files with 25 additions and 3 deletions

1
NEWS
View File

@ -66,6 +66,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
- Will now throw exception on many error conditions during lexer creation; also
throw an exception when MaintainLineNumbers is true, but a non-tracksLineNumbers
is being used.
- Detect if domxml extension is loaded, and use DirectLEx accordingly.
. Strategy_MakeWellFormed now operates in-place, saving memory and allowing
for more interesting filter-backtracking
. New HTMLPurifier_Injector->rewind() functionality, allows injectors to rewind

View File

@ -93,9 +93,15 @@ class HTMLPurifier_Lexer
break;
}
if (class_exists('DOMDocument') && method_exists('DOMDocument', 'loadHTML')) {
// check for DOM support, because, surprisingly enough,
// it's *not* part of the core!
if (
class_exists('DOMDocument') &&
method_exists('DOMDocument', 'loadHTML') &&
!extension_loaded('domxml')
) {
// check for DOM support, because while it's part of the
// core, it can be disabled compile time. Also, the PECL
// domxml extension overrides the default DOM, and is evil
// and nasty and we shan't bother to support it
$lexer = 'DOMLex';
} else {
$lexer = 'DirectLex';

View File

@ -0,0 +1,15 @@
--TEST--
DirectLex with domxml test
--SKIPIF--
<?php
if (!extension_loaded('dom')) {
echo "skip - dom not available";
} elseif (!extension_loaded('domxml')) {
echo "skip - domxml not loaded";
}
--FILE--
<?php
require '../library/HTMLPurifier.auto.php';
echo get_class(HTMLPurifier_Lexer::create(HTMLPurifier_Config::createDefault()));
--EXPECT--
HTMLPurifier_Lexer_DirectLex