77namespace Magento \Eav \Model \Attribute \Data ;
88
99use Magento \Framework \App \RequestInterface ;
10+ use Magento \Framework \Locale \ResolverInterface ;
11+ use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
12+ use Magento \Framework \Stdlib \StringUtils ;
13+ use Psr \Log \LoggerInterface ;
1014
1115/**
1216 * EAV Entity Attribute Text Data Model
@@ -21,20 +25,28 @@ class Text extends \Magento\Eav\Model\Attribute\Data\AbstractData
2125 protected $ _string ;
2226
2327 /**
24- * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
25- * @param \Psr\Log\LoggerInterface $logger
26- * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
27- * @param \Magento\Framework\Stdlib\StringUtils $stringHelper
28+ * @var array
29+ */
30+ private $ encodeAttributesByTypesList ;
31+
32+ /**
33+ * @param TimezoneInterface $localeDate
34+ * @param LoggerInterface $logger
35+ * @param ResolverInterface $localeResolver
36+ * @param StringUtils $stringHelper
37+ * @param array $encodeAttributesByTypesList
2838 * @codeCoverageIgnore
2939 */
3040 public function __construct (
3141 \Magento \Framework \Stdlib \DateTime \TimezoneInterface $ localeDate ,
3242 \Psr \Log \LoggerInterface $ logger ,
3343 \Magento \Framework \Locale \ResolverInterface $ localeResolver ,
34- \Magento \Framework \Stdlib \StringUtils $ stringHelper
44+ \Magento \Framework \Stdlib \StringUtils $ stringHelper ,
45+ array $ encodeAttributesByTypesList = []
3546 ) {
3647 parent ::__construct ($ localeDate , $ logger , $ localeResolver );
3748 $ this ->_string = $ stringHelper ;
49+ $ this ->encodeAttributesByTypesList = $ encodeAttributesByTypesList ;
3850 }
3951
4052 /**
@@ -79,8 +91,10 @@ public function validateValue($value)
7991 return $ errors ;
8092 }
8193
82- // if string with diacritics encode it.
83- $ value = $ this ->encodeDiacritics ($ value );
94+ if (in_array ($ attribute ->getAttributeCode (), $ this ->encodeAttributesByTypesList [$ attribute ->getEntityType ()->getEntityTypeCode ()])) {
95+ // if string with diacritics encode it.
96+ $ value = $ this ->encodeDiacritics ($ value );
97+ }
8498
8599 $ validateLengthResult = $ this ->validateLength ($ attribute , $ value );
86100 $ errors = array_merge ($ errors , $ validateLengthResult );
0 commit comments