You are here:  » Clean HTML and a tags from product descriptions

Support Forum



Clean HTML and a tags from product descriptions

Submitted by webie on Mon, 2009-05-04 15:22 in

Hi Dave,

I think i have fixed the problem now for HTML Unicode characters i added this below to admin.php to convert Unicode then used strip_tags already in price tapestry code and added pre match to remove any links inside the product descriptions i posted it here to ask if you can look at it and to see if you think there will be any problems with it?

It has removed 98% of html from data mind you only tested on one xml file! but it would not remove these tags ' #x0D; not sure why my lack of php knowledge no doubt?

$record[$admin_importFeed["field_description"]] = htmlspecialchars_decode($record[$admin_importFeed["field_description"]]);
$record[$admin_importFeed["field_description"]] = preg_replace('/(<a[^>]*>)(.*?)(<\/a>)/is','', $record[$admin_importFeed["field_description"]]);
$record[$admin_importFeed["field_description"]] = strip_tags($record[$admin_importFeed["field_description"]]);
$record[$admin_importFeed["field_description"]] = preg_replace('/\s\s+/', ' ', $record[$admin_importFeed["field_description"]]);
$record[$admin_importFeed["field_description"]] = str_replace("#x0D;","",$record[$admin_importFeed["field_description"]]);
$record[$admin_importFeed["field_description"]] = str_replace("&apos;","'",$record[$admin_importFeed["field_description"]]);

Kind Regards

Darren

Submitted by support on Tue, 2009-05-05 09:10

Hi Darren,

It's possible that the & part of the entity is itself encoded into &amp; so your str_replace search strings would need to be:

str_replace("&amp;#x0D;","",$record[$admin_importFeed["field_description"]]);
$record[$admin_importFeed["field_description"]] = str_replace("&amp;apos;","'",$record[$admin_importFeed["field_description"]]);

Cheers,
David.