Forums / Bug Reports / [Done v1.6.0] CHARSET and charsetClean (potential bug?)

[Done v1.6.0] CHARSET and charsetClean (potential bug?)

Started by paulm on 12 Apr 2013, 9:42 AM · Views: 1,068

Results 1 to 3 of 3
12 Apr 2013, 9:42 AM
#1
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

[Done v1.6.0] CHARSET and charsetClean (potential bug?)

Maybe not a bug as such, because it looks like this function is not currently used by the Zen Cart core or any other code. I just happened to notice it when I was checking how Zen Cart handles encoding.

But this function (in includes/functions/functions_general.php)

  function charsetClean($string) {
    if (CHARSET == 'UTF-8') return $string;
    if (function_exists('iconv')) $string = iconv("Windows-1252", CHARSET . "//IGNORE", $string);
    $string = htmlentities($string, ENT_QUOTES, 'UTF-8');
    $string = html_entity_decode($string, ENT_QUOTES, CHARSET);
    return $string;
  }
```Won't work as intended because the default CHARSET setting in Zen Cart is defined in english.php as utf-8, not UTF-8.  So the *if (CHARSET == 'UTF-8')* line will never be true (unless someone changes the CHARSET setting to UTF-8).

Not sure if this function will ever be used, or that it's just some legacy code or something.
12 Apr 2013, 5:59 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: [Done v1.6.0] CHARSET and charsetClean (potential bug?)

Yes it is a bug.

No it does not affect anything, since that function is not used in core code at the present time.

Thanks for pointing it out.

Something like this would be better:

    if (preg_replace('/[^a-z0-9]/', '', strtolower(CHARSET)) == 'utf8') return $string;

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Apr 2013, 7:57 PM
#3
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: [Done v1.6.0] CHARSET and charsetClean (potential bug?)

Thanks for the reply.

And your suggestion looks good, I will use it for the Twitter sidebox add on :smile: