Permalink
Browse files

fixed bug with cdata sections that have line breaks in them

git-svn-id: http://svn.php.net/repository/pear/packages/XML_Beautifier/trunk@156636 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
Stephan Schmidt
Stephan Schmidt committed Apr 20, 2004
1 parent fc20dd0 commit fb6b9b2d01b00d16b718b169396863f685daf1e4
Showing with 13 additions and 7 deletions.
  1. +5 −5 Beautifier/Renderer.php
  2. +2 −1 examples/example2.php
  3. +6 −1 examples/test.xml
View
@@ -100,14 +100,14 @@ function _normalizeToken($token)
$children = $token["children"];
$token["children"] = array();
$cnt = count($children);
- $inCData = false;
+ $currentMode = 0;
for ($i = 0; $i < $cnt; $i++ )
{
// no data section
- if ($children[$i]["type"] != XML_BEAUTIFIER_CDATA) {
+ if ($children[$i]["type"] != XML_BEAUTIFIER_CDATA && $children[$i]["type"] != XML_BEAUTIFIER_CDATA_SECTION) {
$children[$i] = $this->_normalizeToken($children[$i]);
- $inCData = false;
+ $currentMode = 0;
array_push($token["children"], $children[$i]);
continue;
}
@@ -123,7 +123,7 @@ function _normalizeToken($token)
}
}
- if ($inCData) {
+ if ($currentMode == $children[$i]["type"]) {
$tmp = array_pop($token["children"]);
if( $children[$i]['data'] != '' ) {
@@ -137,7 +137,7 @@ function _normalizeToken($token)
array_push($token["children"], $children[$i]);
}
- $inCData = true;
+ $currentMode = $children[$i]["type"];
}
return $token;
}
View
@@ -10,7 +10,8 @@
*/
error_reporting( E_ALL );
- $xmlString = '<xml><foo bar="tomato &amp; Cheese"/><argh>foobar<![CDATA[ Test ]]></argh></xml>';
+ $xmlString = '<xml><foo bar="tomato &amp; Cheese"/><argh>foobar<![CDATA[ Test
+ Test ]]></argh></xml>';
require_once 'XML/Beautifier.php';
$fmt = new XML_Beautifier();
View
@@ -36,7 +36,12 @@ Application Tools &amp; PEAR!</introtitle>
<link url=
"/about/project.xml">
"About Pat"</link>
-or
+or
+<![CDATA[
+This CData section has several
+lines and an &amp; as well as an & in
+it...
+]]>
check out the
<link url="/about/projectsOverview.xml">"projects overview"</link>. Otherwise, you probably know your way
around

0 comments on commit fb6b9b2

Please sign in to comment.