Don't allow HTML in product descriptions

  • Posts: 112
  • Thank you received: 1
8 years 2 months ago #249997

-- 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.

  • Posts: 112
  • Thank you received: 1
8 years 2 months ago #250004

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.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 2 months ago #250029

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

	$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
	$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
	$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
	$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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Last edit: 8 years 2 months ago by Jerome.

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

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