Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-15263 Fixed numeric entities remaining after html_to_text

  • Loading branch information...
commit d517630b6339412111c55616677c4015e0cc483b 1 parent 12ab8a5
sam_marshall authored
Showing with 21 additions and 1 deletion.
  1. +14 −0 lib/simpletest/testweblib.php
  2. +7 −1 lib/weblib.php
View
14 lib/simpletest/testweblib.php
@@ -40,5 +40,19 @@ function test_format_string() {
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('<p>This is a <strong>test</strong></p>',FORMAT_HTML));
+ $this->assertEqual('This is a test',
+ format_text_email('<p class="frogs">This is a <strong class=\'fishes\'>test</strong></p>',FORMAT_HTML));
+ $this->assertEqual('& so is this',
+ format_text_email('<p>&amp; so is this</p>',FORMAT_HTML));
+ $tl = textlib_get_instance();
+ $this->assertEqual('Two bullets: '.$tl->code2utf8(8226).' '.$tl->code2utf8(8226),
+ format_text_email('<p>Two bullets: &#x2022; &#8226;</p>',FORMAT_HTML));
+ $this->assertEqual($tl->code2utf8(0x7fd2).$tl->code2utf8(0x7fd2),
+ format_text_email('<p>&#x7fd2;&#x7FD2;</p>',FORMAT_HTML));
+ }
}
?>
View
8 lib/weblib.php
@@ -2231,7 +2231,13 @@ function html_to_text($html) {
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;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.