MDL-25018 stop html_to_text from breaking utf-8 multibyte characters.
This commit is contained in:
+2
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 WORLD’S a stage.", html_to_text('<p>All the <strong>world’s</strong> a stage.</p>'));
|
||||
}
|
||||
|
||||
public function test_clean_text() {
|
||||
$text = "lala <applet>xx</applet>";
|
||||
$this->assertEqual($text, clean_text($text, FORMAT_PLAIN));
|
||||
|
||||
Reference in New Issue
Block a user