Skip to content

Commit

Permalink
Fix idn_to_... deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed May 29, 2019
1 parent d27a283 commit 18e19ba
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
},
"zendframework/zend-http:2.6.0": {
"Remove support for the X-Original-Url and X-Rewrite-Url headers": "zendframework/zend-http/no-x-original-url-x-rewrite.patch"
},
"zendframework/zend-mail:2.7.3": {
"Fix idn_to_ascii deprecation warning": "zendframework/zend-mail/fix-idn_to_ascii-deprecation-warning.patch"
},
"zendframework/zend-validator:2.8.2": {
"Fix idn_to_ascii/idn_to_utf8 deprecation warning": "zendframework/zend-validator/fix-idn_to_-deprecation-warning.patch"
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions zendframework/zend-mail/fix-idn_to_ascii-deprecation-warning.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
From: Filippo Tessarotto <zoeslam@gmail.com>
Date: Fri, 29 Dec 2017 16:30:07 +0100
Subject: [PATCH] Fix idn_to_ascii deprecation warning

--- a/src/Header/AbstractAddressList.php
+++ b/src/Header/AbstractAddressList.php
@@ -102,6 +102,9 @@ public function getFieldName()
protected function idnToAscii($domainName)
{
if (extension_loaded('intl')) {
+ if (defined('INTL_IDNA_VARIANT_UTS46')) {
+ return (idn_to_ascii($domainName, 0, INTL_IDNA_VARIANT_UTS46) ?: $domainName);
+ }
return (idn_to_ascii($domainName) ?: $domainName);
}
return $domainName;
31 changes: 31 additions & 0 deletions zendframework/zend-validator/fix-idn_to_-deprecation-warning.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From: Michele Locati <michele@locati.it>
Date: Wed, 29 May 2019 18:26:58 +0200
Subject: [PATCH] Fix idn_to_ascii/idn_to_utf8 deprecation warning

Fix the "INTL_IDNA_VARIANT_2003 is deprecated" warning

Co-Authored-By: Filippo Tessarotto <zoeslam@gmail.com>
Co-Authored-By: Abdul Malik Ikhsan <samsonasik@gmail.com>

--- a/src/EmailAddress.php
+++ b/src/EmailAddress.php
@@ -535,6 +535,9 @@ class EmailAddress extends AbstractValidator
protected function idnToAscii($email)
{
if (extension_loaded('intl')) {
+ if (defined('INTL_IDNA_VARIANT_UTS46')) {
+ return (idn_to_ascii($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email);
+ }
return (idn_to_ascii($email) ?: $email);
}
return $email;
@@ -554,6 +557,9 @@ class EmailAddress extends AbstractValidator
// the source string in those cases.
// But not when the source string is long enough.
// Thus we default to source string ourselves.
+ if (defined('INTL_IDNA_VARIANT_UTS46')) {
+ return idn_to_utf8($email, 0, INTL_IDNA_VARIANT_UTS46) ?: $email;
+ }
return idn_to_utf8($email) ?: $email;
}
return $email;

0 comments on commit 18e19ba

Please sign in to comment.