Skip to content

Commit b2f1063

Browse files
committed
ACP2E-2037: encode only email address and ignore rp_token from validation
1 parent 2abc466 commit b2f1063

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

app/code/Magento/Customer/etc/di.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,23 @@
578578
<item name="store_id" xsi:type="string">store_id</item>
579579
<item name="group_id" xsi:type="string">group_id</item>
580580
<item name="dob" xsi:type="string">dob</item>
581+
<item name="rp_token" xsi:type="string">rp_token</item>
581582
</item>
582583
<item name="customer_address" xsi:type="array">
583584
<item name="country_id" xsi:type="string">country_id</item>
584585
</item>
585586
</argument>
586587
</arguments>
587588
</type>
589+
<type name="Magento\Eav\Model\Attribute\Data\Text">
590+
<arguments>
591+
<argument name="encodeAttributesByTypesList" xsi:type="array">
592+
<item name="customer" xsi:type="array">
593+
<item name="email" xsi:type="string">email</item>
594+
</item>
595+
</argument>
596+
</arguments>
597+
</type>
588598
<type name="Magento\AsynchronousOperations\Model\MassSchedule">
589599
<plugin name="anonymousAsyncCustomerRequest"
590600
type="Magento\Customer\Plugin\AsyncRequestCustomerGroupAuthorization"

app/code/Magento/Eav/Model/Attribute/Data/Text.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
namespace Magento\Eav\Model\Attribute\Data;
88

99
use 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

Comments
 (0)