From f36b87d1d680875c314926a35583793fc261f047 Mon Sep 17 00:00:00 2001
From: Dries Buytaert
Date: Sat, 10 Apr 2010 10:01:15 +0000
Subject: - Patch #721536 by JacobSingh, jpmckinney, Damien Tournoud,
David_Rothstein: HTML corrector filter has problems with unescaped CDATA and
incorrectly closed tags.
---
modules/field/modules/text/text.test | 10 +++++-----
modules/filter/filter.module | 4 ++--
modules/filter/filter.test | 19 ++++++++++++++-----
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/modules/field/modules/text/text.test b/modules/field/modules/text/text.test
index 6e9c41ac4..cbd135f74 100644
--- a/modules/field/modules/text/text.test
+++ b/modules/field/modules/text/text.test
@@ -309,11 +309,11 @@ class TextSummaryTestCase extends DrupalWebTestCase {
$expected_lb = array(
"\nHi\n
\n\nfolks\n
\n!\n
",
"",
- "",
- "",
- "",
- "",
- "",
+ "",
+ "",
+ "",
+ "",
+ "",
"\nHi
",
"\nHi
",
"\nHi
",
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index def0037c8..1daf7e8de 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -983,7 +983,7 @@ function _filter_tips($format_id, $long = FALSE) {
*/
function filter_dom_load($text) {
// Ignore warnings during HTML soup loading.
- $dom_document = @DOMDocument::loadHTML('' . $text . '');
+ $dom_document = @DOMDocument::loadHTML('' . $text . '');
return $dom_document;
}
@@ -1018,7 +1018,7 @@ function filter_dom_serialize($dom_document) {
foreach ($body_node->childNodes as $child_node) {
$body_content .= $dom_document->saveXML($child_node);
}
- return preg_replace('|<([^>]*)/>|i', '<$1 />', $body_content);
+ return preg_replace('|<([^> ]*)/>|i', '<$1 />', $body_content);
}
/**
diff --git a/modules/filter/filter.test b/modules/filter/filter.test
index 3c4a35ee3..b9e3f760a 100644
--- a/modules/filter/filter.test
+++ b/modules/filter/filter.test
@@ -1003,7 +1003,7 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
$this->assertEqual($f, 'text
', t('HTML corrector -- tag closing at the end of input.'));
$f = _filter_htmlcorrector('text
text');
- $this->assertEqual($f, '
text
text
', t('HTML corrector -- tag closing.'));
+ $this->assertEqual($f, 'text
text
', t('HTML corrector -- tag closing.'));
$f = _filter_htmlcorrector("- e1
- e2");
$this->assertEqual($f, "", t('HTML corrector -- unclosed list tags.'));
@@ -1021,14 +1021,17 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
$f = _filter_htmlcorrector('
test
');
$this->assertEqual($f, 'test
', t('HTML corrector -- Convert uppercased tags to proper lowercased ones.'));
+ $f = _filter_htmlcorrector('test
');
+ $this->assertEqual($f, 'test
', t('HTML corrector -- Let proper XHTML pass through.'));
+
$f = _filter_htmlcorrector('test
');
- $this->assertEqual($f, 'test
', t('HTML corrector -- Let proper XHTML pass thru.'));
+ $this->assertEqual($f, 'test
', t('HTML corrector -- Let proper XHTML pass through, but ensure there is a single space before the closing slash.'));
- $f = _filter_htmlcorrector('test
');
- $this->assertEqual($f, 'test
', t('HTML corrector -- Let proper XHTML pass thru.'));
+ $f = _filter_htmlcorrector('test
');
+ $this->assertEqual($f, 'test
', t('HTML corrector -- Let proper XHTML pass through, but ensure there are not too many spaces before the closing slash.'));
$f = _filter_htmlcorrector('');
- $this->assertEqual($f, '', t('HTML corrector -- Let proper XHTML pass thru.'));
+ $this->assertEqual($f, '', t('HTML corrector -- Convert XHTML that is properly formed but that would not be compatible with typical HTML user agents.'));
$f = _filter_htmlcorrector('test1
test2');
$this->assertEqual($f, 'test1
test2', t('HTML corrector -- Automatically close single tags.'));
@@ -1042,6 +1045,12 @@ class FilterUnitTestCase extends DrupalUnitTestCase {
$f = _filter_htmlcorrector('
test');
$this->assertEqual($f, '
test', t('HTML corrector -- Automatically close single tags.'));
+ $f = _filter_htmlcorrector('
');
+ $this->assertEqual($f, '
', t("HTML corrector -- Transform empty tags to a single closed tag if the tag's content model is EMPTY."));
+
+ $f = _filter_htmlcorrector('');
+ $this->assertEqual($f, '', t("HTML corrector -- Do not transform empty tags to a single closed tag if the tag's content model is not EMPTY."));
+
$f = _filter_htmlcorrector('line1
line2
');
$this->assertEqual($f, 'line1
line2', t('HTML corrector -- Move non-inline elements outside of inline containers.'));
--
cgit v1.2.3