diff options
author | Andrey Andreev <narf@devilix.net> | 2018-01-22 13:29:50 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2018-01-22 13:29:50 +0100 |
commit | 6545f8595480ab64220aacc8a5176383dac4122b (patch) | |
tree | 31e9f0a592801fe07dba5d99a3b73526d10b101f /system/libraries | |
parent | 3738910fce3192054cd2815d814ab261c3d3868c (diff) | |
parent | 329dd039a211ed7634b45e2c908f7dc375b806a2 (diff) |
Merge branch '3.1-stable' into develop
Conflicts resolved:
system/libraries/Email.php
system/libraries/Form_validation.php
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/Email.php | 21 | ||||
-rw-r--r-- | system/libraries/Form_validation.php | 5 |
2 files changed, 22 insertions, 4 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php index f9a4ae733..1847cc96f 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1012,9 +1012,12 @@ class CI_Email { */ public function valid_email($email) { - if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@')) + if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $email, $matches)) { - $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), 0, INTL_IDNA_VARIANT_UTS46); + $domain = defined('INTL_IDNA_VARIANT_UTS46') + ? idn_to_ascii($matches[2], 0, INTL_IDNA_VARIANT_UTS46) + : idn_to_ascii($matches[2]); + $email = $matches[1].'@'.$domain; } return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); @@ -2027,7 +2030,19 @@ class CI_Email { $this->_send_command('hello'); $this->_send_command('starttls'); - $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); + /** + * STREAM_CRYPTO_METHOD_TLS_CLIENT is quite the mess ... + * + * - On PHP <5.6 it doesn't even mean TLS, but SSL 2.0, and there's no option to use actual TLS + * - On PHP 5.6.0-5.6.6, >=7.2 it means negotiation with any of TLS 1.0, 1.1, 1.2 + * - On PHP 5.6.7-7.1.* it means only TLS 1.0 + * + * We want the negotiation, so we'll force it below ... + */ + $method = is_php('5.6') + ? STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT + : STREAM_CRYPTO_METHOD_TLS_CLIENT; + $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, $method); if ($crypto !== TRUE) { diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index f402459a9..9e4c81c61 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1237,7 +1237,10 @@ class CI_Form_validation { { if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $str, $matches)) { - $str = $matches[1].'@'.idn_to_ascii($matches[2], 0, INTL_IDNA_VARIANT_UTS46); + $domain = defined('INTL_IDNA_VARIANT_UTS46') + ? idn_to_ascii($matches[2], 0, INTL_IDNA_VARIANT_UTS46) + : idn_to_ascii($matches[2]); + $str = $matches[1].'@'.$domain; } return (bool) filter_var($str, FILTER_VALIDATE_EMAIL); |