Menu

Drupal LDAP invalid multibyte

February 10, 2014 - Uncategorized

After enabling the LDAP modules in Drupal 7 I was trying to test my config. Using the test function in the module it was returning the user information as expected along with several lines similar to this.

Warning: htmlspecialchars(): Invalid multibyte sequence in argument in check_plain() (line 1572 of /var/www/drupal/includes/bootstrap.inc

I found the following post:

https://drupal.org/comment/6647386#comment-6647386

And replaced the following code:

function check_plain($text) {
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}

With this:
function check_plain($text) {
if (!mb_detect_encoding($text, 'UTF-8', true)) {
$text = mb_convert_encoding($text, 'UTF-8', 'ISO-8859-1');
}
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}

And the warning has gone away.

Tags: ,

Leave a Reply