Skip to content

Commit bbf16a0

Browse files
authored
Merge pull request #150 from magento-commerce/fix/catalog-upload-striptags-issue
added conditional check before calling strip_tags and replace strip_t…
2 parents 00b9979 + 5dcc247 commit bbf16a0

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

app/code/Meta/Catalog/Model/Product/Feed/Builder.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
use Magento\Catalog\Model\Product;
2929
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
3030
use Magento\Framework\Exception\LocalizedException;
31+
use Magento\Framework\Escaper;
32+
use Magento\Framework\Filter\StripTagsFactory;
3133
use Magento\Customer\Model\GroupManagement;
3234

3335
class Builder
@@ -108,13 +110,24 @@ class Builder
108110
*/
109111
private $inventoryOnly = false;
110112

113+
/**
114+
* @var Escaper
115+
*/
116+
private $escaper;
117+
118+
/**
119+
* @var StripTagsFactory
120+
*/
121+
private $stripTags;
122+
111123
/**
112124
* @param FBEHelper $fbeHelper
113125
* @param SystemConfig $systemConfig
114126
* @param CategoryCollectionFactory $categoryCollectionFactory
115127
* @param BuilderTools $builderTools
116128
* @param ProductIdentifier $productIdentifier
117129
* @param CatalogHelper $catalogHelper
130+
* @param StripTagsFactory $stripTags
118131
*/
119132
public function __construct(
120133
FBEHelper $fbeHelper,
@@ -123,7 +136,9 @@ public function __construct(
123136
BuilderTools $builderTools,
124137
ProductIdentifier $productIdentifier,
125138
CatalogHelper $catalogHelper,
126-
InventoryInterface $inventory
139+
InventoryInterface $inventory,
140+
Escaper $escaper,
141+
StripTagsFactory $stripTags
127142
)
128143
{
129144
$this->fbeHelper = $fbeHelper;
@@ -133,6 +148,8 @@ public function __construct(
133148
$this->productIdentifier = $productIdentifier;
134149
$this->catalogHelper = $catalogHelper;
135150
$this->inventory = $inventory;
151+
$this->escaper = $escaper;
152+
$this->stripTags = $stripTags;
136153
}
137154

138155
/**
@@ -390,8 +407,12 @@ private function getRichDescription(Product $product)
390407
if (!$description) {
391408
$description = $product->getShortDescription();
392409
}
410+
if (!$description) {
411+
return '';
412+
}
413+
$stripTags = $this->stripTags->create([$this->escaper, self::ALLOWED_TAGS_FOR_RICH_TEXT_DESCRIPTION]);
393414
return $this->trimAttribute(self::ATTR_RICH_DESCRIPTION,
394-
strip_tags($description, self::ALLOWED_TAGS_FOR_RICH_TEXT_DESCRIPTION));
415+
$stripTags->filter($description));
395416
}
396417

397418
/**

0 commit comments

Comments
 (0)