From 7588068b7b54e83eae11b3cf3dd55ea167d86227 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 27 Aug 2006 22:06:58 +0000 Subject: [PATCH] Hacky full docuement parse thingy removed from DOMLex, fixes barfing on full HTML documents. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@328 48356398-32a2-884e-a903-53898d9a118a --- library/HTMLPurifier/Lexer.php | 3 +-- library/HTMLPurifier/Lexer/DOMLex.php | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/library/HTMLPurifier/Lexer.php b/library/HTMLPurifier/Lexer.php index 1f004ea9..1dd984b6 100644 --- a/library/HTMLPurifier/Lexer.php +++ b/library/HTMLPurifier/Lexer.php @@ -295,10 +295,9 @@ class HTMLPurifier_Lexer /** * Takes a string of HTML (fragment or document) and returns the content */ - function extractBody($html, $return_bool = false) { + function extractBody($html) { $matches = array(); $result = preg_match('!]*>(.+?)!is', $html, $matches); - if ($return_bool) return $result; if ($result) { return $matches[1]; } else { diff --git a/library/HTMLPurifier/Lexer/DOMLex.php b/library/HTMLPurifier/Lexer/DOMLex.php index 9def5257..230e694e 100644 --- a/library/HTMLPurifier/Lexer/DOMLex.php +++ b/library/HTMLPurifier/Lexer/DOMLex.php @@ -37,7 +37,7 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer if (!$config) $config = HTMLPurifier_Config::createDefault(); if ($config->get('Core', 'AcceptFullDocuments')) { - $is_full = $this->extractBody($string, true); + $string = $this->extractBody($string); } $doc = new DOMDocument(); @@ -55,9 +55,8 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer // clean it into well-formed UTF-8 string $string = $this->cleanUTF8($string); - if (!$is_full) { // preprocess string, essential for UTF-8 - $string = + $string = ''. @@ -65,7 +64,6 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer ''. '
'.$string.'
'; - } @$doc->loadHTML($string); // mute all errors, handle it transparently