mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 15:28:40 +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:
parent
f7bc0b0875
commit
d304c5c976
1
NEWS
1
NEWS
@ -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
|
||||
|
@ -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';
|
||||
|
15
tests/HTMLPurifier/PHPT/domxml.phpt
Normal file
15
tests/HTMLPurifier/PHPT/domxml.phpt
Normal 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
|
Loading…
Reference in New Issue
Block a user