mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #54648
[Bug 1836588] [NEW] Multibyte comments broken
Public bug reported:
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);
** Affects: mahara
Importance: High
Status: New
** Attachment added: "Page comment broken screenshot"
https://bugs.launchpad.net/bugs/1836588/+attachment/5277165/+files/mahara_comment.png
** Changed in: mahara
Importance: Undecided => High
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1836588
Title:
Multibyte comments broken
Status in Mahara:
New
Bug description:
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);
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1836588/+subscriptions
Follow ups
-
[Bug 1836588] Re: Multibyte comments broken
From: Robert Lyon, 2019-10-31
-
[Bug 1836588] Re: Multibyte comments broken
From: Lisa Seeto, 2019-10-31
-
[Bug 1836588] Re: Multibyte comments broken
From: Mitsuhiro Yoshida, 2019-09-20
-
[Bug 1836588] A change has been merged
From: Mahara Bot, 2019-09-19
-
[Bug 1836588] A patch has been submitted for review
From: Mahara Bot, 2019-09-19
-
[Bug 1836588] A change has been merged
From: Mahara Bot, 2019-09-19
-
[Bug 1836588] Re: Multibyte comments broken
From: Robert Lyon, 2019-09-19
-
[Bug 1836588] A patch has been submitted for review
From: Mahara Bot, 2019-09-08
-
[Bug 1836588] Re: Multibyte comments broken
From: Kristina Hoeppner, 2019-09-08
-
[Bug 1836588] Re: Multibyte comments broken
From: Mitsuhiro Yoshida, 2019-07-16
-
[Bug 1836588] Re: Multibyte comments broken
From: Mitsuhiro Yoshida, 2019-07-16