Skip to content

Commit e027cd2

Browse files
committed
Merge branch 'fix-for-issue-12075' of github.com:Alexander-Khohklov/magento2 into 2.4-develop-prs
2 parents 6dbb7fc + 5a03926 commit e027cd2

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ public function validateValue($value)
7979
return $errors;
8080
}
8181

82+
// if string with diacritics encode it.
83+
$value = $this->encodeDiacritics($value);
84+
8285
$validateLengthResult = $this->validateLength($attribute, $value);
8386
$errors = array_merge($errors, $validateLengthResult);
8487

@@ -173,4 +176,19 @@ private function validateInputRule(string $value): array
173176
$result = $this->_validateInputRule($value);
174177
return \is_array($result) ? $result : [];
175178
}
179+
180+
/**
181+
* Encode strings with diacritics for validate.
182+
*
183+
* @param array|string $value
184+
* @return array|string
185+
*/
186+
private function encodeDiacritics($value): array|string
187+
{
188+
$encoded = $value;
189+
if (is_string($value)) {
190+
$encoded = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value);
191+
}
192+
return $encoded;
193+
}
176194
}

app/code/Magento/Eav/Test/Unit/Model/Attribute/Data/TextTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ public function alphanumWithSpacesDataProvider(): array
199199
];
200200
}
201201

202+
/**
203+
* Test for string with diacritics validation
204+
*/
205+
public function testValidateValueStringWithDiacritics(): void
206+
{
207+
$inputValue = "á â à å ä ð é ê è ë í î ì ï ó ô ò ø õ ö ú û ù ü æ œ ç ß a ĝ ń ŕ ý ð ñ";
208+
$expectedResult = true;
209+
self::assertEquals($expectedResult, $this->model->validateValue($inputValue));
210+
}
211+
202212
/**
203213
* @param array $attributeData
204214
* @return Attribute

0 commit comments

Comments
 (0)