Skip to main content

Don't allow HTML in product descriptions

10 years 2 months ago #249997 by darrelluk
-- HikaShop version -- : 3.7.1
-- HikaMarket version -- : 1.7.1
-- Joomla version -- : 3.6.2

I was told to post this in Hikamarket.

How do I prevent users from using HTML in product descriptions? What code and where do I need to change on the Product page so that it keeps it to simple text?

Thx, Darrell

Please Log in or Create an account to join the conversation.

10 years 2 months ago #250004 by darrelluk
Finally figured how to stop vendors from using crazy font sizes, colours etc.

System > Global Configuration > Text Filters

Find the filter group you have assigned to your vendors.

> Filter type = NO HTML
> Filter Tags = p,br,b,i (to allow basic formatting)

You then go to...

Components > Hikashop > Hikamarket > Configuration > Editor > plg_editors_none

This will remove the editor altogether on the product description field and prevent any HTML tags apart from the ones allowed above to be used, even if you paste text in.

Thx, Darrell

Please Log in or Create an account to join the conversation.

10 years 2 months ago - 10 years 2 months ago #250029 by Jerome
Hi,

Thanks for your post in that section.

In the HikaMarket product class (administrator/components/com_hikamarket/classes/product.php), you will find that code
Code:
$product->product_description = JRequest::getVar('product_description','','','string',JREQUEST_ALLOWRAW); if((int)$config->get('vendor_safe_product_description', 1)) { $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); $product->product_description = $safeHtmlFilter->clean($product->product_description, 'string'); }
You can replace that code by
Code:
$product->product_description = JRequest::getVar('product_description','','','string',JREQUEST_ALLOWRAW); if((int)$config->get('vendor_safe_product_description', 1)) { $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); $product->product_description = $safeHtmlFilter->clean($product->product_description, 'string'); } $strip_tags = $config->get('vendor_striptags_product_description', ''); if(!empty($strip_tags)) { $product->product_description = strip_tags($product->product_description, $strip_tags); }
So you will have a new hidden setting to completely remove all HTML tags in the product description when a vendor edit a product.

You can also replace in the same file
Code:
$product->product_description = JRequest::getVar('product_variant_description','','','string',JREQUEST_ALLOWRAW); $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); $product->product_description = $safeHtmlFilter->clean($product->product_description, 'string');
By
Code:
$product->product_description = JRequest::getVar('product_variant_description','','','string',JREQUEST_ALLOWRAW); if((int)$config->get('vendor_safe_product_description', 1)) { $safeHtmlFilter = JFilterInput::getInstance(null, null, 1, 1); $product->product_description = $safeHtmlFilter->clean($product->product_description, 'string'); } $strip_tags = $config->get('vendor_striptags_product_description', ''); if(!empty($strip_tags)) { $product->product_description = strip_tags($product->product_description, $strip_tags); }
So the variants will also have that hidden setting available.

Please note that the patch will be integrated into next HikaMarket release.

For more details about "strip_tags" : php.net/manual/en/function.strip-tags.php

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Last edit: 10 years 2 months ago by Jerome.

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.076 seconds
Powered by Kunena Forum