summaryrefslogtreecommitdiff
path: root/tests/it_html.t
diff options
context:
space:
mode:
authorChristian Helbling2012-04-04 09:25:06 +0000
committerChristian Helbling2012-04-04 09:25:06 +0000
commita0231e4df6f8bfa82451c05998bb349ece764610 (patch)
tree6c1d9e76e8a6388fdf7f1d2435f0da082bd7de62 /tests/it_html.t
parent1336ce6ac3baacd1cecbf776cfafa81f8d025272 (diff)
parent14f1c25b43628013507da706544d5c55cb1bc461 (diff)
downloaditools-a0231e4df6f8bfa82451c05998bb349ece764610.tar.gz
itools-a0231e4df6f8bfa82451c05998bb349ece764610.tar.bz2
itools-a0231e4df6f8bfa82451c05998bb349ece764610.zip
Merged devel-utf8 back into live
Diffstat (limited to 'tests/it_html.t')
-rwxr-xr-xtests/it_html.t59
1 files changed, 43 insertions, 16 deletions
diff --git a/tests/it_html.t b/tests/it_html.t
index 0def431..174c487 100755
--- a/tests/it_html.t
+++ b/tests/it_html.t
@@ -4,6 +4,7 @@
# Tests for html.class
# Traditional html generation
+ini_set('default_charset', "utf-8");
new it_html(array('htmltype' => "html"));
is(
@@ -95,30 +96,22 @@ is(
<P><a href="javascript:window.close()" title="Wolken"><img src="http://farm1.static.flickr.com/177/377214376_bcba167a7d_m.jpg" width="240" height="180" alt="Wolken" style="border: 1px solid #ddd;" /></a></p>
'),
- ' <a href="http://www.flickr.com/people/swisspics%25/">swisspics</a> posted &lt; &lt; &amp; yesterday a <i>photo</i> <i>tag missmatch</i>:<br /><br /> <p><img src="http://farm1.static.flickr.com/177/377214376_bcba167a7d_m.jpg" alt="" /></p> ',
+ ' <a href="http://www.flickr.com/people/swisspics%25/">swisspics</a> posted &lt; &lt; ä &amp; yesterday a <i>photo</i> <i>tag missmatch</i>:<br /><br /> <p><img src="http://farm1.static.flickr.com/177/377214376_bcba167a7d_m.jpg" alt="" /></p> ',
'it_html::sanitize tag soup'
);
is(
it_html::sanitize('q&#8592;x'),
- "q&#8592;x",
+ "q←x",
'it_html::sanitize preserve numeric entities'
);
-it_html::configure(array('charset' => "utf-8"));
is(
it_html::sanitize('q&uuml;x'),
"q\xc3\xbcx",
'it_html::sanitize with utf-8'
);
-it_html::configure(array('charset' => "iso-8859-1"));
-is(
- it_html::sanitize('q&uuml;x'),
- "q\xfcx",
- 'it_html::sanitize with latin1'
-);
-
is(
it_html::sanitize('<b>a<br>b</b>'),
"<b>a<br />b</b>",
@@ -126,8 +119,8 @@ is(
);
is(
- U("/foo.html", array('bar' => array('gna' => 42, 'qux' => array('quux' => "<Zrich>", 'gnp' => "fasel")))),
- '/foo.html?bar[gna]=42&bar[qux][quux]=%3CZ%FCrich%3E&bar[qux][gn%F6p]=fasel',
+ U("/foo.html", array('bar' => array('gna' => 42, 'qux' => array('quux' => "<Zürich>", 'gnöp' => "fasel")))),
+ '/foo.html?bar[gna]=42&bar[qux][quux]=%3CZ%C3%BCrich%3E&bar[qux][gn%C3%B6p]=fasel',
'U() with nested arrays'
);
@@ -149,11 +142,45 @@ is(
'U() converting of \ to /'
);
-is(it_html::entity_decode("&auml;"), "");
-is(it_html::entity_decode("&#8217;"), "'");
+is(it_html::entity_decode("&auml;"), "ä");
is(it_html::entity_decode("&#x4a;"), "J");
is(it_html::entity_decode("&#x4A;"), "J");
-is(it_html::entity_decode("&#xfff;"), " ");
is(it_html::entity_decode("&#65;"), "A");
-is(it_html::entity_decode("&#999;"), " ");
+
+
+#
+# check transliterations in iso-8859-1
+#
+
+it_html::configure(array('charset' => "iso-8859-1"));
+ini_set('default_charset', "iso-8859-1");
+
+is(
+ it_html::sanitize('q&uuml;x'),
+ "q\xfcx",
+ 'it_html::sanitize with latin1'
+);
+
+is(
+ it_html::sanitize('q&#8592;x'),
+ "q&#8592;x",
+ 'it_html::sanitize preserve non-decodable numeric entities'
+);
+is(it_html::entity_decode("&#8217;"), "'", "it_html::entity_decode numeric decimal entity");
+is(it_html::entity_decode("&#xfff;"), " ", "it_html::entity_decode invalid numeric hex entity");
+is(it_html::entity_decode("&#999;"), " ", "it_html::entity_decode invalid numeric decimal entity");
+
+is(it_html::fix_encoding("Meier"), "Meier", "it_html::fix_encoding ascii");
+is(it_html::fix_encoding("Müller"), "Müller", "it_html::fix_encoding utf-8 latin1");
+is(it_html::fix_encoding("Aslı"), "Aslı", "it_html::fix_encoding utf-8 non-latin1");
+is(it_html::fix_encoding("é»"), "é»", "it_html::fix_encoding utf-8 latin1 special combination");
+
+is(it_html::fix_encoding(utf8_encode("Müller"), true), "Müller", "it_html::fix_encoding double encoded latin1");
+is(it_html::fix_encoding(utf8_encode("Aslı"), true), "Aslı", "it_html::fix_encoding double encoded non-latin1");
+is(it_html::fix_encoding(utf8_encode("é»"), true), "é»", "it_html::fix_encoding double encoded latin1 special combination");
+
+is(it_html::fix_encoding(utf8_decode("Müller"), true), "Müller", "it_html::fix_encoding incorrectly encoded latin1");
+
+is(it_html::fix_encoding("a💚b"), "a💚b", "it_html::fix_encoding correctly handles 4-byte utf-8 character GREEN HEART");
+
?>