VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Virtuemart 1.1 Development (Archiv) => Quality & Testing VirtueMart 1.1.x => Topic started by: mauri on June 14, 2008, 12:58:32 PM

Title: cannot yet handle MBCS in html_entity_decode
Post by: mauri on June 14, 2008, 12:58:32 PM
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

Title: Re: cannot yet handle MBCS in html_entity_decode
Post by: Majino on June 17, 2008, 14:59:57 PM
same problem.. please help :D
Title: Re: cannot yet handle MBCS in html_entity_decode
Post by: donmarvin on July 03, 2008, 12:59:26 PM
You can turn off php warnings:

http://www.php.net/manual/en/function.error-reporting.php

You only need to see errors, not warnings.
Title: Re: cannot yet handle MBCS in html_entity_decode
Post by: mauri on July 09, 2008, 19:38:24 PM
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() );
}

Title: Re: cannot yet handle MBCS in html_entity_decode
Post by: mauri on July 10, 2008, 17:51:30 PM
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;
}