News:

Looking for documentation? Take a look on our wiki

Main Menu

cannot yet handle MBCS in html_entity_decode

Started by mauri, June 14, 2008, 12:58:32 PM

Previous topic - Next topic

mauri

I install latest nightlybuild VM1.1.0
In VirtueMart administration get Warning:
Warning: cannot yet handle MBCS in html_entity_decode()! in /administrator/components/com_virtuemart/classes/phpInputFilter/class.inputfilter.php on line 566
line 566 $source = html_entity_decode($source, ENT_QUOTES, vmGetCharset() );
In that line, new thing is vmGetCharset
I know it´s a PHP4 bug, can´t handle UTF-8."vmGetCharset is UTF-8"

J! 1.5.3
VM 1.1.0 rev. 1388
PHP 4.4.8

VirtueMart,(Joomla-phpShop, mambo-phpShop) since 2004-03-11

Majino


donmarvin


mauri

#3
OK, one of my host don´t update to PHP5.
I fix it in that server:
Line 566:
$source = html_entity_decode($source, ENT_QUOTES, vmGetCharset() );

Replace to:

//( In php4 use this instead of html_entity_decode with utf-8)
if(( version_compare( phpversion(), '5.0' ) < 0 ) && (strtolower( vmGetCharset() ) == 'utf-8')) {
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
$source = strtr ($source, $trans_tbl);
$source = utf8_encode($source);
}else{
// url decode (phpversion =< 5.0 or vmGetCharset()!= utf-8 )
$source = @html_entity_decode($source, ENT_QUOTES, vmGetCharset() );
}

VirtueMart,(Joomla-phpShop, mambo-phpShop) since 2004-03-11

mauri

Find more simply way. If you use J!1.5, you can call J! function html_entity_decode_php4()
in /administrator/components/com_virtuemart/classes/phpInputFilter/class.inputfilter.php

function decode($source) {
if( $source != "" ) { //bypass php html_entity_decode bug # 21338 on systems where unable to upgrade php
// url decode
$source = @html_entity_decode($source, ENT_QUOTES, vmGetCharset() );
// convert decimal
$source = preg_replace('/&#(\d+);/me',"chr(\\1)", $source); // decimal notation
// convert hex
$source = preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)", $source); // hex notation
}
return $source;
}


replace:

function decode($source) {
if( $source != "" ) { //bypass php html_entity_decode bug # 21338 on systems where unable to upgrade php
//( In php4 use this instead of html_entity_decode with utf-8)
if(( version_compare( phpversion(), '5.0' ) < 0 ) && (strtolower( vmGetCharset() ) == 'utf-8')) {
require_once(JPATH_SITE.DS.'libraries'.DS.'tcpdf'.DS.'html_entity_decode_php4.php');
$source = html_entity_decode_php4($source);
}else{
// url decode (phpversion =< 5.0)
$source = @html_entity_decode($source, ENT_QUOTES, vmGetCharset() );
}
// convert decimal
$source = preg_replace('/&#(\d+);/me',"chr(\\1)", $source); // decimal notation
// convert hex
$source = preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)", $source); // hex notation
}
return $source;
}

VirtueMart,(Joomla-phpShop, mambo-phpShop) since 2004-03-11