MDL-25018 stop html_to_text from breaking utf-8 multibyte characters.

This commit is contained in:
Tim Hunt
2010-11-02 20:03:48 +00:00
parent 29946ad595
commit 6cb034c9d2
3 changed files with 28 additions and 6 deletions
+2 -4
View File
@@ -580,9 +580,7 @@ class html2text
*/
function _strtoupper($str)
{
if (function_exists('mb_strtoupper'))
return mb_strtoupper($str);
else
return strtoupper($str);
$tl = textlib_get_instance();
return $tl->strtoupper($str);
}
}
+22 -2
View File
@@ -30,6 +30,26 @@ index b7e3e3e..96ef508 100644
}
}
-- Tim Hunt 2010-08-04
-- Tim Hunt 2010-08-04
2- No strip slashes, we do not use magic quotes any more in Moodle 2.0 or later
2- No strip slashes, we do not use magic quotes any more in Moodle 2.0 or later
3- Use textlib, not crappy functions that break UTF-8, in the _strtoupper method.
Index: lib/html2text.php
--- lib/html2text.php 2 Sep 2010 12:49:29 -0000 1.16
+++ lib/html2text.php 2 Nov 2010 19:57:09 -0000
@@ -580,9 +580,7 @@
*/
function _strtoupper($str)
{
- if (function_exists('mb_strtoupper'))
- return mb_strtoupper($str);
- else
- return strtoupper($str);
+ $tl = textlib_get_instance();
+ return $tl->strtoupper($str);
}
}
-- Tim Hunt 2010-11-02
+4
View File
@@ -128,6 +128,10 @@ class web_test extends UnitTestCase {
$this->assertEqual($long, html_to_text($long, 0));
}
public function test_html_to_text_dont_screw_up_utf8() {
$this->assertEqual("\n\nAll the WORLDS a stage.", html_to_text('<p>All the <strong>worlds</strong> a stage.</p>'));
}
public function test_clean_text() {
$text = "lala <applet>xx</applet>";
$this->assertEqual($text, clean_text($text, FORMAT_PLAIN));