From 02e27747f8a92cbf047606d3cf9e208e925fe004 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 5 Oct 2009 11:41:50 +0000 Subject: Fix typo in data sanitizer and added encoding support --- tests/it_xml.t | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/it_xml.t') diff --git a/tests/it_xml.t b/tests/it_xml.t index a0922c5..8c2c084 100755 --- a/tests/it_xml.t +++ b/tests/it_xml.t @@ -3,11 +3,11 @@ # Tests for xml.class -function match($xmldata, $expected, $name, $prefix = "") +function match($xmldata, $expected, $name, $prefix = "", $p = array()) { $classname = $prefix ? ($prefix . "_xml") : "it_xml"; $varname = $prefix . "foo"; - $xml = new $classname("$xmldata"); + $xml = new $classname("$xmldata", $p); is( preg_replace('/[#\s]+/', " ", print_r($xml->$varname, true)), @@ -47,9 +47,17 @@ match( ); match( - '&<>&<>&<> ü', - 'foo Object ( [val] => &<>&<>&<> ü ) ', - 'Predecode illegal entities', + '&amp; <a> &amp; <b> &amp; <c> ü', + 'foo Object ( [val] => & & & ü ) ', + 'Predecode illegal entities while keeping properly encoded ones', +); + +match( + '&amp; <a> &amp; <b> &amp; <c> ü', + utf8_encode('foo Object ( [val] => & & & ü ) '), + 'Predecode illegal entities while keeping properly encoded ones (UTF-8)', + "", + array('encoding' => "UTF-8"), ); -- cgit v1.2.3