43
43
use Eccube \Stream \Filter \SjisToUtf8EncodingFilter ;
44
44
use Eccube \Util \CacheUtil ;
45
45
use Eccube \Util \StringUtil ;
46
+ use HTMLPurifier ;
46
47
use Sensio \Bundle \FrameworkExtraBundle \Configuration \Template ;
47
48
use Symfony \Component \Filesystem \Filesystem ;
48
49
use Symfony \Component \Finder \Finder ;
@@ -127,6 +128,8 @@ class CsvImportController extends AbstractCsvImportController
127
128
128
129
protected $ currentLineNo = 1 ;
129
130
131
+ private HTMLPurifier $ purifier ;
132
+
130
133
/**
131
134
* CsvImportController constructor.
132
135
*
@@ -142,7 +145,7 @@ class CsvImportController extends AbstractCsvImportController
142
145
* @param TaxRuleRepository $taxRuleRepository
143
146
* @param BaseInfoRepository $baseInfoRepository
144
147
* @param ValidatorInterface $validator
145
- *
148
+ * @param HTMLPurifier $purifier
146
149
* @throws \Exception
147
150
*/
148
151
public function __construct (
@@ -157,7 +160,8 @@ public function __construct(
157
160
ProductRepository $ productRepository ,
158
161
TaxRuleRepository $ taxRuleRepository ,
159
162
BaseInfoRepository $ baseInfoRepository ,
160
- ValidatorInterface $ validator
163
+ ValidatorInterface $ validator ,
164
+ HTMLPurifier $ purifier
161
165
) {
162
166
$ this ->deliveryDurationRepository = $ deliveryDurationRepository ;
163
167
$ this ->saleTypeRepository = $ saleTypeRepository ;
@@ -171,6 +175,7 @@ public function __construct(
171
175
$ this ->taxRuleRepository = $ taxRuleRepository ;
172
176
$ this ->BaseInfo = $ baseInfoRepository ->get ();
173
177
$ this ->validator = $ validator ;
178
+ $ this ->purifier = $ purifier ;
174
179
}
175
180
176
181
/**
@@ -319,7 +324,7 @@ public function csvProduct(Request $request, CacheUtil $cacheUtil)
319
324
320
325
if (isset ($ row [$ headerByKey ['description_list ' ]])) {
321
326
if (StringUtil::isNotBlank ($ row [$ headerByKey ['description_list ' ]])) {
322
- $ Product ->setDescriptionList (StringUtil::trimAll ($ row [$ headerByKey ['description_list ' ]]));
327
+ $ Product ->setDescriptionList ($ this -> purifier -> purify ( StringUtil::trimAll ($ row [$ headerByKey ['description_list ' ]]) ));
323
328
} else {
324
329
$ Product ->setDescriptionList (null );
325
330
}
@@ -337,7 +342,7 @@ public function csvProduct(Request $request, CacheUtil $cacheUtil)
337
342
338
343
return $ this ->renderWithError ($ form , $ headers );
339
344
} else {
340
- $ Product ->setDescriptionDetail (StringUtil::trimAll ($ row [$ headerByKey ['description_detail ' ]]));
345
+ $ Product ->setDescriptionDetail ($ this -> purifier -> purify ( StringUtil::trimAll ($ row [$ headerByKey ['description_detail ' ]]) ));
341
346
}
342
347
} else {
343
348
$ Product ->setDescriptionDetail (null );
@@ -354,7 +359,7 @@ public function csvProduct(Request $request, CacheUtil $cacheUtil)
354
359
355
360
if (isset ($ row [$ headerByKey ['free_area ' ]])) {
356
361
if (StringUtil::isNotBlank ($ row [$ headerByKey ['free_area ' ]])) {
357
- $ Product ->setFreeArea (StringUtil::trimAll ($ row [$ headerByKey ['free_area ' ]]));
362
+ $ Product ->setFreeArea ($ this -> purifier -> purify ( StringUtil::trimAll ($ row [$ headerByKey ['free_area ' ]]) ));
358
363
} else {
359
364
$ Product ->setFreeArea (null );
360
365
}
@@ -796,7 +801,7 @@ public function csvCategory(Request $request, CacheUtil $cacheUtil)
796
801
$ ParentCategory = null ;
797
802
if (isset ($ row [$ headerByKey ['parent_category_id ' ]]) && StringUtil::isNotBlank ($ row [$ headerByKey ['parent_category_id ' ]])) {
798
803
if (!preg_match ('/^\d+$/ ' , $ row [$ headerByKey ['parent_category_id ' ]])) {
799
- $ this ->addErrors (($ data ->key () + 1 ).'行目の親カテゴリIDが存在しません 。 ' );
804
+ $ this ->addErrors (($ data ->key () + 1 ).'行目の親カテゴリIDは数字で入力してください 。 ' );
800
805
801
806
return $ this ->renderWithError ($ form , $ headers );
802
807
}
0 commit comments