Hi
i get this warning after install the dev module on my php 4 (PHP 4.4.4-8+etch6) installation of Drupal 6.16
warning: cannot yet handle MBCS in html_entity_decode()! in ./sites/all/modules/link/link.module on line 29.

CommentFileSizeAuthor
#4 link_html_fix.tar_.gz34.44 KBjcfiala

Comments

transformative’s picture

I got the same warning (it appears about fifty times in a row, on every page, and so makes editing the site unreasonable). This post explains that it is likely a PHP 4 vs. PHP 5 issue: http://drupal.org/node/103432. If you're lucky enough to be able to upgrade to PHP 5, I'm guessing that would fix it.

Near the bottom of the link that they refer to (http://bugs.php.net/bug.php?id=25670), there is a suggested solution (posted at 2003-09-27 02:11 UTC). That would need to be a module hack on the link module though, which isn't great.

I'm not sure how it'll work, but you could try something like changing line 29 from:

// There are many other characters which are legal other than simply a-z - this includes them.
define('LINK_ICHARS', (string) html_entity_decode(implode("", array(

to:

function unhtmlentities($string)
{
    // replace numeric entities
    $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
    $string = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $string);
    // replace literal entities
    $trans_tbl = get_html_translation_table(HTML_ENTITIES);
    $trans_tbl = array_flip($trans_tbl);
    return strtr($string, $trans_tbl);
}

// There are many other characters which are legal other than simply a-z - this includes them.
define('LINK_ICHARS', (string) unhtmlentities(implode("", array(

Better still, see if you can get your host to upgrade to PHP 5...

chromix’s picture

It seems silly to require PHP 5 for this one line of code when Drupal 5 requires PHP 4. Either way your patch worked great! Thank you for posting it.

jcfiala’s picture

Assigned: Unassigned » jcfiala

A bug in PHP4, huh? How crazy.

I'll include this fix before I release the next version.

jcfiala’s picture

StatusFileSize
new34.44 KB

Okay folks, I've done up a possible fix. It's passing tests for me in PHP 5, but then again, it's hard to say given that the problem is with PHP4.

I'm going to try and whip up a test environment with PHP 4 in a moment, but if someone could test this version of link and give me feedback, that would be a big help.

jcfiala’s picture

Hm. My attempts to test on PHP4 have gone flat - Anyone have a server we can test this code on?

jcfiala’s picture

Well, I wasn't able to test on PHP4, but I found that the code originally suggested in this thread doesn't quite work when running on PHP5. I'm using the suggestion at http://www.php.net/manual/en/function.html-entity-decode.php#75153, and it runs fine in PHP5... which means I hope it runs in PHP4.

I'll be submitting this change to the server, assuming the tests currently running succeed, and hopefully someone can get back to me with feedback then.

jcfiala’s picture

Status: Active » Fixed

Okay, I've patched the code in 2.x-dev - wait for today's changes to hit the downloadable version, and give it a try.

eule’s picture

hi
i try it again but no hope

warning: cannot yet handle MBCS in html_entity_decode()! in ./sites/all/modules/link/link.module on line 29.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.