Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Location
    Haarlem | Netherlands
    Posts
    1,987
    Plugin Contributions
    15

    Default [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)
    Code:
      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.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: 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:
    Code:
        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.

  3. #3
    Join Date
    Nov 2003
    Location
    Haarlem | Netherlands
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: CHARSET and charsetClean (potential bug?)

    Thanks for the reply.

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

 

 

Similar Threads

  1. Replies: 0
    Last Post: 20 Feb 2013, 12:15 PM
  2. [Not a bug] [1.5.0BETA] UTF-8 Charset
    By gob33 in forum Bug Reports
    Replies: 2
    Last Post: 31 Jul 2011, 11:31 PM
  3. [Done v1.3.8] Database cache bug and fix
    By bouncingltd in forum Bug Reports
    Replies: 19
    Last Post: 14 Jul 2009, 03:26 PM
  4. [Done v1.3.9] Chmod and insert into sessions bug
    By Anders Moen in forum Bug Reports
    Replies: 1
    Last Post: 23 Mar 2008, 03:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR