Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2009
    Location
    Texas
    Posts
    209
    Plugin Contributions
    2

    Default Manufacters names in dropdown menus being html converted.

    In 1.5 I noticed that a manufacturer in my manufacturers drop down box was showing T&S instead of being converted to T&S.

    I hunted this down. And it would seem the code at includes/modules/sideboxes/manufacturers.php has changed causing this problem.

    At around line 52 in 1.3.9h we have:

    Code:
       while (!$manufacturer_sidebox->EOF) {
          $manufacturer_sidebox_name = ((strlen($manufacturer_sidebox->fields['manufacturers_name']) > MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturer_sidebox->fields['manufacturers_name'], 0, MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturer_sidebox->fields['manufacturers_name']);
    In 1.5.1 we have:

    Code:
    $manufacturer_sidebox_name = zen_output_string(((strlen($manufacturer_sidebox->fields['manufacturers_name']) > (int)MAX_DISPLAY_MANUFACTURER_NAME_LEN) ? substr($manufacturer_sidebox->fields['manufacturers_name'], 0, (int)MAX_DISPLAY_MANUFACTURER_NAME_LEN) . '..' : $manufacturer_sidebox->fields['manufacturers_name']), false, true);
    The problem seems to be the zen_output_string and more importantly is the fact this is being sent as PROTECTED=true. This causes htmlspecialchars to be run on the string. Which causes & to turn into &&

    Now a simple solution I guess is to change the manufacturer to T&S instead of T&S. That solves the manufacturers drop down.. but causes HTML errors everywhere else my manufacturer name is.

    For now I've just made this piece of code not be protected by changing the last true to false. This seems to work right.

    Something is inconsistent here though. Either Zen Cart needs to change ampersands or leave them alone.

  2. #2
    Join Date
    Jul 2009
    Location
    Texas
    Posts
    209
    Plugin Contributions
    2

    Default Re: Manufacters names in dropdown menus being html converted.

    To make sure this wasn't an add-on or module I've tested in a clean copy of 1.5.1 with demo products. Add a manufacturer to the system with a & and then tack it to a product and you'll see what I mean in the manufacturers dropdown.

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,502
    Plugin Contributions
    88

    Default Re: Manufacters names in dropdown menus being html converted.

    I'm responsible for this, since I suggested the change from v1.3.9h to v1.5.0 having noticed that the manufacturers' sidebox on my home page didn't validate if I had an ampersand in a manufacturer's name. Unlike you, I didn't take it further, checking that having an & instead of & also caused validation issues in my products' listings and information pages.

    I agree with your assessment; if an ampersand in a manufacturer's name can't be solved globally via code, it should at least be dealt with consistently. As such, I recommend that the change that was incorporated at my suggestion be backed out of the next ZC codebase and that the policy going forward be that if a manufacturer's name includes an ampersand (&) that the name be specified in the database using &

  4. #4
    Join Date
    Jul 2009
    Location
    Texas
    Posts
    209
    Plugin Contributions
    2

    Default Re: Manufacters names in dropdown menus being html converted.

    I think that might be easiest. Ideally I wouldn't mind if most everything converted. It's been a pain to tell people to use & instead of a normal ampersand. (Not that it really makes a difference, I can't think of any browser that chokes on this sort of thing)

    But I don't know if I'd like my descriptions converted, as I use a lot HTML there. I think I also oddly have some attributes which I'm injecting with HTML to make look a little better.

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

    Default Re: Manufacters names in dropdown menus being html converted.

    Internal testing suggests this is resolved in v1.6.0 pre-alpha code (accessible on Github).

    I would appreciate if one of you can confirm this.
    .

    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.

  6. #6
    Join Date
    Jul 2009
    Location
    Texas
    Posts
    209
    Plugin Contributions
    2

    Default Re: Manufacters names in dropdown menus being html converted.

    Quote Originally Posted by DrByte View Post
    Internal testing suggests this is resolved in v1.6.0 pre-alpha code (accessible on Github).

    I would appreciate if one of you can confirm this.
    Tested on code pulled from github this morning. Can confirm irregularities still exist.

    Test procedure:

    Installed 1.6 pre-alpha using normal installation, did not install demo products.
    Created two manufacturers one with just an ampersand (T & S) and one with an ampersand quoted (Pelton & Crane)
    Created two products and attached to manufacturers.
    Visited product pages.

    On the product info section the manufacturer name shows up as inputted:
    <span itemprop="brand">T&S</span>
    <span itemprop="brand">Pelton &amp; Crane</span>

    The first case will cause the HTML error we all love. The second is 'correct'.

    However in the manufacturers side box we have:
    <option value="2">Pelton &amp;amp; Cr..</option>
    <option value="1">T&amp;S</option>

    As you can see both have been attempted to be quoted, yet the Pelton and Crane entry did not need it.

    What I think needs to happen here is that on output nothing is translated and outputs as it is in the database, however on all inputs I think we need to check explicitly for an ampersand alone and quote if necessary.

    Or just don't mess with the quoting at all. Allow us nitpickers to put in the HTML correctly to get rid of mostly harmless HTML errors.

 

 

Similar Threads

  1. Replies: 3
    Last Post: 21 Jun 2016, 09:49 PM
  2. v151 Ampersands Not Being Converted
    By Feznizzle in forum General Questions
    Replies: 11
    Last Post: 6 Feb 2016, 04:37 PM
  3. Dropdown Menus
    By Question in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 15 Oct 2009, 01:52 AM
  4. dropdown menus
    By wolfsden in forum Setting Up Categories, Products, Attributes
    Replies: 10
    Last Post: 14 Jun 2008, 07:13 PM
  5. Dropdown names and values, editin html output
    By mrmarcus66 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 20 Dec 2006, 11:46 AM

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