Index: lib/simpletest/testweblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/simpletest/testweblib.php,v retrieving revision 1.6 diff -u -r1.6 testweblib.php --- lib/simpletest/testweblib.php 9 Jun 2007 16:32:36 -0000 1.6 +++ lib/simpletest/testweblib.php 16 Jun 2008 13:49:19 -0000 @@ -40,5 +40,19 @@ function test_s() { $this->assertEqual(s("This Breaks \" Strict"), "This Breaks " Strict"); } + + function test_format_text_email() { + $this->assertEqual('This is a test', + format_text_email('

This is a test

',FORMAT_HTML)); + $this->assertEqual('This is a test', + format_text_email('

This is a test

',FORMAT_HTML)); + $this->assertEqual('& so is this', + format_text_email('

& so is this

',FORMAT_HTML)); + $tl = textlib_get_instance(); + $this->assertEqual('Two bullets: '.$tl->code2utf8(8226).' '.$tl->code2utf8(8226), + format_text_email('

Two bullets: • •

',FORMAT_HTML)); + $this->assertEqual($tl->code2utf8(0x7fd2).$tl->code2utf8(0x7fd2), + format_text_email('

習習

',FORMAT_HTML)); + } } ?> Index: lib/weblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v retrieving revision 1.970.2.90 diff -u -r1.970.2.90 weblib.php --- lib/weblib.php 26 May 2008 11:47:00 -0000 1.970.2.90 +++ lib/weblib.php 16 Jun 2008 13:49:19 -0000 @@ -2231,7 +2231,13 @@ require_once($CFG->libdir .'/html2text.php'); - return html2text($html); + $result = html2text($html); + + // html2text does not fix numerical entities so handle those here. + $tl=textlib_get_instance(); + $result = $tl->entities_to_utf8($result,false); + + return $result; } /**