Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    help question Textarea returns plain-text instead of HTML text for custom product type

    I'm currently using 1.5.7c.

    I have a custom product type that uses two textboxes, one the default "product" description and the other a special field for that product type. When I click on "Preview", the HTML appears in raw, unescaped form in the "new_product_preview" . When I click on "Back" (through ZenCart Admin, not the browser), the HTML textbox is preloaded with the unescaped HTML text.

    What have I missed on the update? Any assistance would be appreciated.

    Screencap for reference:

    What is being submitted for preview:


    What is shown on the preview:


    What is presented when going back:

  2. #2
    Join Date
    Jul 2007
    Posts
    342
    Plugin Contributions
    7

    Default Re: Textarea returns plain-text instead of HTML text for custom product type

    Have you tried clicking on the Source icon top left and then adding HTML Text

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

    Default Re: Textarea returns plain-text instead of HTML text for custom product type

    @retched, does your custom product addition include an admin 'sanitizer' for those additional textarea fields, enabling them to include HTML content?

  4. #4
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    Default Re: Textarea returns plain-text instead of HTML text for custom product type

    Quote Originally Posted by lat9 View Post
    @retched, does your custom product addition include an admin 'sanitizer' for those additional textarea fields, enabling them to include HTML content?
    @lat9, I don't believe so. This was a hard copy/porting of it from 1.5.3 to now. Where would I find that in the code to emulate in my custom product type? I'm noticing that it is coming back from `$_POST` as the correct text, if that helps.

  5. #5
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    Default Re: Textarea returns plain-text instead of HTML text for custom product type

    Quote Originally Posted by ianhg View Post
    Have you tried clicking on the Source icon top left and then adding HTML Text
    Similar problem still. The source text before I send it to process is proper HTML but evidently something is still causing it to return the plain HTML instead of the proper HTML.

  6. #6
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    Default Re: Textarea returns plain-text instead of HTML text for custom product type

    Quote Originally Posted by retched View Post
    @lat9, I don't believe so. This was a hard copy/porting of it from 1.5.3 to now. Where would I find that in the code to emulate in my custom product type? I'm noticing that it is coming back from `$_POST` as the correct text, if that helps.
    So in a spree of throwing everything against the wall and seeing what sticks:

    I think I managed to fix this but I feel like it's a REALLY rough edit. I added the field name of the textarea to line 226 in init_sanitize.php where it ends up on this

    Code:
    $sanitizer->addSimpleSanitization('PRODUCT_DESC_REGEX', $group)
    .

    After I made this change, everything end up working as needed. So I guess the question I should ask is, where should I make this change so that it doesn't overwrite the main core files.

  7. #7
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Re: Textarea returns plain-text instead of HTML text for custom product type

    Create your change-specific sanitization in /admin/extra_datafiles/something_sanitizer.php.

    The name doesn't matter as long as it's unique and reminds you of what's being sanitized. The file's contents should be similar to:
    Code:
    <?php
    // -----
    // Admin-level sanitizations for my specific changes
    //
    $my_sanitizer = AdminRequestSanitizer::getInstance();
    
    $my_group_sanitize = [
        'field_name_1',
        'field_name_2',
    ];
    $my_sanitizer->addSimpleSanitization('PRODUCT_DESC_REGEX', $my_group_sanitize);
    The field_names are the names of the posted variables that you've added.

  8. #8
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    521
    Plugin Contributions
    3

    Default Re: Textarea returns plain-text instead of HTML text for custom product type

    That works perfectly, I'll go ahead and make sure that I do this on each custom type.

  9. #9
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Re: Textarea returns plain-text instead of HTML text for custom product type

    Quote Originally Posted by retched View Post
    That works perfectly, I'll go ahead and make sure that I do this on each custom type.
    Great, I'm happy to have helped.

  10. #10
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Textarea returns plain-text instead of HTML text for custom product type

    Quote Originally Posted by retched View Post
    That works perfectly, I'll go ahead and make sure that I do this on each custom type.
    The following may include more than desired at the moment, but is a good reference for accomplishing admin sanitization:
    Admin Request Sanitization | Zen Cart Documentation (zen-cart.com)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v157 html contact us plain text
    By pixelpadre in forum Basic Configuration
    Replies: 4
    Last Post: 28 Jul 2021, 09:54 PM
  2. v139g Change Street Address to textarea instead of text
    By wackyracer8 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 19 Nov 2012, 01:40 AM
  3. HTML Editor preview changes to Plain Text with HTML code
    By Morph99 in forum Basic Configuration
    Replies: 5
    Last Post: 3 Jan 2011, 10:12 PM
  4. HTML - plain text for sending emails V1.3.8
    By eOstrE in forum General Questions
    Replies: 2
    Last Post: 17 Jul 2009, 09:00 AM
  5. Plain text/HTML add text or...
    By Monica79 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 14 Mar 2009, 06:32 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