Drupal: Added UTF-8 encoding for HTML being loaded by DOMDocument. Fixes garbage output text for links and moderator links.

https://dev.gridrepublic.org/browse/DBOINCP-359
This commit is contained in:
Shawn Kwang 2017-03-08 10:54:43 -06:00
parent 72d6849c5a
commit 4ceda504bb
1 changed files with 2 additions and 2 deletions

View File

@ -714,7 +714,7 @@ function _boinc_create_moderator_links(&$links, &$moderator_links) {
// Create an array of HTML elements from the $links string, keys
// are the class attribute for the <li> tags.
$dom = new DOMDocument;
$dom->loadHTML($links);
$dom->loadHTML(mb_convert_encoding($links, 'HTML-ENTITIES', 'UTF-8'));
foreach($dom->getElementsByTagName('li') as $node) {
$key = $node->getAttribute("class");
$alllinks[$key] = $dom->saveHTML($node);
@ -754,7 +754,7 @@ function _boinc_create_moderator_links(&$links, &$moderator_links) {
function _boinc_firstlink(&$alink) {
if (!empty($alink)) {
$dom = new DomDocument;
$dom->loadHTML($alink);
$dom->loadHTML(mb_convert_encoding($alink, 'HTML-ENTITIES', 'UTF-8'));
$myli = $dom->getElementsByTagName('li');
if ($myli->length>0) {