Author Topic: cannot yet handle MBCS in html_entity_decode  (Read 10804 times)

mauri

  • Quality&Testing Team
  • Jr. Member
  • *
  • Posts: 297
cannot yet handle MBCS in html_entity_decode
« 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
Code: [Select]
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

  • Beginner
  • *
  • Posts: 20
Re: cannot yet handle MBCS in html_entity_decode
« Reply #1 on: June 17, 2008, 14:59:57 pm »
same problem.. please help :D

donmarvin

  • Jr. Member
  • **
  • Posts: 67
Re: cannot yet handle MBCS in html_entity_decode
« Reply #2 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.

mauri

  • Quality&Testing Team
  • Jr. Member
  • *
  • Posts: 297
Re: cannot yet handle MBCS in html_entity_decode
« Reply #3 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:
Code: [Select]
$source = html_entity_decode($source, ENT_QUOTES, vmGetCharset() );
Replace to:
Code: [Select]
//( 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

  • Quality&Testing Team
  • Jr. Member
  • *
  • Posts: 297
Re: cannot yet handle MBCS in html_entity_decode
« Reply #4 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

Code: [Select]
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:

Code: [Select]
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