28
28
use Magento \Catalog \Model \Product ;
29
29
use Magento \Catalog \Model \ResourceModel \Category \CollectionFactory as CategoryCollectionFactory ;
30
30
use Magento \Framework \Exception \LocalizedException ;
31
+ use Magento \Framework \Escaper ;
32
+ use Magento \Framework \Filter \StripTagsFactory ;
31
33
use Magento \Customer \Model \GroupManagement ;
32
34
33
35
class Builder
@@ -108,13 +110,24 @@ class Builder
108
110
*/
109
111
private $ inventoryOnly = false ;
110
112
113
+ /**
114
+ * @var Escaper
115
+ */
116
+ private $ escaper ;
117
+
118
+ /**
119
+ * @var StripTagsFactory
120
+ */
121
+ private $ stripTags ;
122
+
111
123
/**
112
124
* @param FBEHelper $fbeHelper
113
125
* @param SystemConfig $systemConfig
114
126
* @param CategoryCollectionFactory $categoryCollectionFactory
115
127
* @param BuilderTools $builderTools
116
128
* @param ProductIdentifier $productIdentifier
117
129
* @param CatalogHelper $catalogHelper
130
+ * @param StripTagsFactory $stripTags
118
131
*/
119
132
public function __construct (
120
133
FBEHelper $ fbeHelper ,
@@ -123,7 +136,9 @@ public function __construct(
123
136
BuilderTools $ builderTools ,
124
137
ProductIdentifier $ productIdentifier ,
125
138
CatalogHelper $ catalogHelper ,
126
- InventoryInterface $ inventory
139
+ InventoryInterface $ inventory ,
140
+ Escaper $ escaper ,
141
+ StripTagsFactory $ stripTags
127
142
)
128
143
{
129
144
$ this ->fbeHelper = $ fbeHelper ;
@@ -133,6 +148,8 @@ public function __construct(
133
148
$ this ->productIdentifier = $ productIdentifier ;
134
149
$ this ->catalogHelper = $ catalogHelper ;
135
150
$ this ->inventory = $ inventory ;
151
+ $ this ->escaper = $ escaper ;
152
+ $ this ->stripTags = $ stripTags ;
136
153
}
137
154
138
155
/**
@@ -390,8 +407,12 @@ private function getRichDescription(Product $product)
390
407
if (!$ description ) {
391
408
$ description = $ product ->getShortDescription ();
392
409
}
410
+ if (!$ description ) {
411
+ return '' ;
412
+ }
413
+ $ stripTags = $ this ->stripTags ->create ([$ this ->escaper , self ::ALLOWED_TAGS_FOR_RICH_TEXT_DESCRIPTION ]);
393
414
return $ this ->trimAttribute (self ::ATTR_RICH_DESCRIPTION ,
394
- strip_tags ($ description, self :: ALLOWED_TAGS_FOR_RICH_TEXT_DESCRIPTION ));
415
+ $ stripTags -> filter ($ description ));
395
416
}
396
417
397
418
/**
0 commit comments