When we post English and Japanese comments on a page "Add comment" field, only Japanese characters are corrupted as the attached screenshot (mahara_comment.png).
We can fix the issue using mb_convert_encoding function as below. Hopefully this fix helps Mahara multibyte character users.
---------------------------
Program file to modify:
artefact/comment/lib.php
Line number to modify;
1184
[ Before ]
/*
* Removes the classes from the text of the comment that could interfere
* with the comment display
* @param string $comment the text content of the comment
*/
public static function remove_comments_classes($comment) {
if (empty($comment)) {
return "";
}
$dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadHTML($comment, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$xpath = new DOMXPath($dom);
[ After ]
/*
* Removes the classes from the text of the comment that could interfere
* with the comment display
* @param string $comment the text content of the comment
*/
public static function remove_comments_classes($comment) {
if (empty($comment)) {
return "";
}
$dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true;
// $dom->loadHTML($comment, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
if (function_exists('mb_convert_encoding')) { $dom->loadHTML(mb_convert_encoding($comment, 'HTML-ENTITIES', 'UTF-8'));
} else $dom->loadHTML($comment, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
}
$xpath = new DOMXPath($dom);
When we post English and Japanese comments on a page "Add comment" field, only Japanese characters are corrupted as the attached screenshot (mahara_ comment. png).
We can fix the issue using mb_convert_encoding function as below. Hopefully this fix helps Mahara multibyte character users.
------- ------- ------- ------
Program file to modify: comment/ lib.php
artefact/
Line number to modify;
1184
[ Before ] comments_ classes( $comment) {
/*
* Removes the classes from the text of the comment that could interfere
* with the comment display
* @param string $comment the text content of the comment
*/
public static function remove_
if (empty($comment)) {
$dom-> preserveWhiteSp ace = false;
$dom-> formatOutput = true;
$dom-> loadHTML( $comment, LIBXML_ HTML_NOIMPLIED | LIBXML_ HTML_NODEFDTD) ;
return "";
}
$dom = new DOMDocument();
$xpath = new DOMXPath($dom);
[ After ] comments_ classes( $comment) {
/*
* Removes the classes from the text of the comment that could interfere
* with the comment display
* @param string $comment the text content of the comment
*/
public static function remove_
if (empty($comment)) {
$dom-> preserveWhiteSp ace = false;
$dom-> formatOutput = true; $comment, LIBXML_ HTML_NOIMPLIED | LIBXML_ HTML_NODEFDTD) ; exists( 'mb_convert_ encoding' )) {
$dom- >loadHTML( mb_convert_ encoding( $comment, 'HTML-ENTITIES', 'UTF-8'));
$dom- >loadHTML( $comment, LIBXML_ HTML_NOIMPLIED | LIBXML_ HTML_NODEFDTD) ;
return "";
}
$dom = new DOMDocument();
// $dom->loadHTML(
if (function_
} else
}
$xpath = new DOMXPath($dom);