Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 4e4e836

Browse files
committed
Merge branch 'hotfix/66'
Close #66
2 parents 219f048 + 4b9d264 commit 4e4e836

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ All notable changes to this project will be documented in this file, in reverse
4141
[#148](https://github.com/zendframework/zend-validator/pull/110) adds further
4242
`"suggest"` clauses in `composer.json`, since some dependencies are not always
4343
required, and may lead to runtime failures.
44+
- [#66](https://github.com/zendframework/zend-validator/pull/66) fixed
45+
EmailAddress validator applying IDNA conversion to local part
4446

4547

4648
## 2.8.2 - 2017-01-29

src/EmailAddress.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ protected function validateLocalPart()
340340
// atext: ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*",
341341
// "+", "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~"
342342
$atext = 'a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d\x3f\x5e\x5f\x60\x7b\x7c\x7d\x7e';
343-
if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->idnToAscii($this->localPart))) {
343+
if (preg_match('/^[' . $atext . ']+(\x2e+[' . $atext . ']+)*$/', $this->localPart)) {
344344
$result = true;
345345
} else {
346346
// Try quoted string format (RFC 5321 Chapter 4.1.2)
@@ -379,7 +379,7 @@ protected function validateMXRecords()
379379
{
380380
$mxHosts = [];
381381
$weight = [];
382-
$result = getmxrr($this->idnToAscii($this->hostname), $mxHosts, $weight);
382+
$result = getmxrr($this->hostname, $mxHosts, $weight);
383383
if (! empty($mxHosts) && ! empty($weight)) {
384384
$this->mxRecord = array_combine($mxHosts, $weight) ?: [];
385385
} else {
@@ -473,7 +473,7 @@ protected function splitEmailParts($value)
473473
}
474474

475475
$this->localPart = $matches[1];
476-
$this->hostname = $matches[2];
476+
$this->hostname = $this->idnToAscii($matches[2]);
477477

478478
return true;
479479
}
@@ -497,7 +497,7 @@ public function isValid($value)
497497
}
498498

499499
$length = true;
500-
$this->setValue($this->idnToUtf8($value));
500+
$this->setValue($value);
501501

502502
// Split email address up and disallow '..'
503503
if (! $this->splitEmailParts($this->getValue())) {

test/EmailAddressTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function testEmailDisplay()
220220
public function validEmailAddresses()
221221
{
222222
// @codingStandardsIgnoreStart
223-
return [
223+
$return = [
224224
225225
226226
@@ -232,6 +232,13 @@ public function validEmailAddresses()
232232
'bob@verylongdomainsupercalifragilisticexpialidociousspoonfulofsugar.com' => ['bob@verylongdomainsupercalifragilisticexpialidociousspoonfulofsugar.com'],
233233
234234
];
235+
236+
if (extension_loaded('intl')) {
237+
$return['bob@тест.рф'] = ['bob@тест.рф'];
238+
239+
}
240+
241+
return $return;
235242
// @codingStandardsIgnoreEnd
236243
}
237244

@@ -269,6 +276,7 @@ public function invalidEmailAddresses()
269276
'bob @ domain.com' => ['bob @ domain.com'],
270277
271278
279+
'иван@письмо.рф' => ['иван@письмо.рф'],
272280
'multiline' => ['bob
273281
274282
@domain.com'],
@@ -741,8 +749,8 @@ public function testUseMxCheckBasicValid()
741749
];
742750

743751
if (extension_loaded('intl')) {
744-
$emailAddresses[] = 'иван@письмо.рф';
745-
$emailAddresses[] = 'xn--@-7sbfxdyelgv5j.xn--p1ai';
752+
$emailAddresses[] = 'test@письмо.рф';
753+
$emailAddresses[] = 'test@xn--h1aigbl0e.xn--p1ai';
746754
}
747755

748756
foreach ($emailAddresses as $input) {

0 commit comments

Comments
 (0)