From 92ecf1a9a9e55d8ab4777b93796d114b6954103e Mon Sep 17 00:00:00 2001
From: Peter Philipp <peter.philipp@cando-image.com>
Date: Tue, 8 Nov 2011 21:37:58 +0100
Subject: [PATCH] Issue #998590 by Charles51, das-peter: Prevent double CDATA
 section escaping in
 filter_dom_serialize_escape_cdata_element() to avoid
 warnings

---
 core/modules/filter/filter.test |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/core/modules/filter/filter.test b/core/modules/filter/filter.test
index 67d0833..22ed7ff 100644
--- a/core/modules/filter/filter.test
+++ b/core/modules/filter/filter.test
@@ -1637,6 +1637,23 @@ alert("test")
  /* Styling */ body {color:red}
 /*--><!]]>*/
 </style></p>', t('HTML corrector -- CDATA added to a style element.'));
+
+    // Check if doubling cdata escaping is prevented.
+    $cdata_patterns = array(
+      '<!--//--><![CDATA[// ><!-- ' => '<p><script type="text/javascript"><!--//--><![CDATA[// ><!-- alert("test");//--><!]]></script></p>',
+      '// <![CDATA[' => '<p><script type="text/javascript">// <![CDATA[alert("test");// ]]></script></p>',
+      '//<![CDATA[' => '<p><script type="text/javascript">//<![CDATA[alert("test");//]]></script></p>',
+      '<!--/*--><![CDATA[/* ><!--*/' => '<p><style><!--/*--><![CDATA[/* ><!--*/ /* Styling */ body {color:red} /*--><!]]>*/</style></p>',
+      '/*<![CDATA[*/' => '<p><style>/*<![CDATA[*/ /* Styling */ body {color:red} /*]]>*/</style></p>',
+    );
+    foreach ($cdata_patterns as $pattern_name => $pattern_data) {
+      $f = _filter_htmlcorrector($pattern_data);
+      $this->assertEqual(
+        $f,
+        $pattern_data,
+        t('HTML corrector -- Existing @pattern_name kept and not doubled up', array('@pattern_name' => $pattern_name))
+      );
+    }
   }
 
   /**
-- 
1.7.7.msysgit.1

