mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-08 07:06:46 +02:00
Add CDATA support to the Lexers, as well as give PEARSax3 entity replacement.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@106 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -27,8 +27,14 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
||||
|
||||
public function tokenizeHTML($string) {
|
||||
$doc = new DOMDocument();
|
||||
|
||||
// preprocess string
|
||||
$string = '<html><body><div>'.$string.'</div></body></html>';
|
||||
|
||||
// replace and escape the CDATA sections, since parsing under HTML
|
||||
// mode won't get 'em.
|
||||
$string = $this->escapeCDATA($string);
|
||||
|
||||
@$doc->loadHTML($string); // mute all errors, handle it transparently
|
||||
return $this->tokenizeDOM(
|
||||
$doc->childNodes->item(1)-> // html
|
||||
@@ -55,7 +61,8 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
|
||||
if ( !($node instanceof DOMElement) ) {
|
||||
if ($node instanceof DOMComment) {
|
||||
$tokens[] = new HTMLPurifier_Token_Comment($node->data);
|
||||
} elseif ($node instanceof DOMText) {
|
||||
} elseif ($node instanceof DOMText ||
|
||||
$node instanceof DOMCharacterData) {
|
||||
$tokens[] = new HTMLPurifier_Token_Text($node->data);
|
||||
}
|
||||
// quite possibly, the object wasn't handled, that's fine
|
||||
|
Reference in New Issue
Block a user