correction : filtre adresse e-mail avec nom de domaine internationalisé
https://framagit.org/framasoft/framadate/merge_requests/268
This commit is contained in:
parent
cdd1840217
commit
1d8244fd99
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
namespace Framadate\Services;
|
||||
use DateTime;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
|
||||
/**
|
||||
* This class helps to clean all inputs from the users or external services.
|
||||
|
@ -66,42 +68,24 @@ class InputService {
|
|||
|
||||
public function filterMail($mail) {
|
||||
|
||||
$mail = mb_strtolower(trim($mail));
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// formatting
|
||||
|
||||
$mail = trim($mail);
|
||||
|
||||
$decoupage = explode("@", $mail, 2);
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// e-mail validation
|
||||
|
||||
$resultat = FALSE;
|
||||
|
||||
|
||||
if (isset($decoupage[1])) {
|
||||
|
||||
$domaine = idn_to_ascii(
|
||||
$decoupage[1]
|
||||
, IDNA_DEFAULT
|
||||
, INTL_IDNA_VARIANT_UTS46
|
||||
);
|
||||
|
||||
$adresseConvertie = "{$decoupage[0]}@$domaine";
|
||||
|
||||
$adresseFiltree = filter_var(
|
||||
$adresseConvertie
|
||||
, FILTER_VALIDATE_EMAIL
|
||||
, ["flags" => FILTER_FLAG_EMAIL_UNICODE] // permet d'utiliser des accents avant le @
|
||||
);
|
||||
|
||||
if ($adresseConvertie === $adresseFiltree) {
|
||||
|
||||
$testMX = getmxrr($domaine, $_); // tester sur le domaine indique un serveur MX
|
||||
|
||||
if ($testMX) {
|
||||
$resultat = $mail;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$validator = new EmailValidator();
|
||||
|
||||
if ($validator->isValid($mail, new RFCValidation())) {
|
||||
$resultat = $mail;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// return
|
||||
|
||||
return $resultat;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,8 @@
|
|||
"phpmailer/phpmailer": "^5.2",
|
||||
"ircmaxell/password-compat": "dev-master",
|
||||
"roave/security-advisories": "dev-master",
|
||||
"erusev/parsedown": "^1.7"
|
||||
"erusev/parsedown": "^1.7",
|
||||
"egulias/email-validator": "~2.1"
|
||||
},
|
||||
|
||||
"require-dev": {
|
||||
|
|
|
@ -4,8 +4,119 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a3ca2dd4f87562095f8c19a94560fed7",
|
||||
"content-hash": "40759eac537218b0212ed923261b9850",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
"version": "v1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/lexer.git",
|
||||
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c",
|
||||
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Lexer\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"lexer",
|
||||
"parser"
|
||||
],
|
||||
"time": "2014-09-09T13:34:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "egulias/email-validator",
|
||||
"version": "2.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/egulias/EmailValidator.git",
|
||||
"reference": "1bec00a10039b823cc94eef4eddd47dcd3b2ca04"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/1bec00a10039b823cc94eef4eddd47dcd3b2ca04",
|
||||
"reference": "1bec00a10039b823cc94eef4eddd47dcd3b2ca04",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/lexer": "^1.0.1",
|
||||
"php": ">= 5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"dominicsayers/isemail": "dev-master",
|
||||
"phpunit/phpunit": "^4.8.35",
|
||||
"satooshi/php-coveralls": "^1.0.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Egulias\\EmailValidator\\": "EmailValidator"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Eduardo Gulias Davis"
|
||||
}
|
||||
],
|
||||
"description": "A library for validating emails against several RFCs",
|
||||
"homepage": "https://github.com/egulias/EmailValidator",
|
||||
"keywords": [
|
||||
"email",
|
||||
"emailvalidation",
|
||||
"emailvalidator",
|
||||
"validation",
|
||||
"validator"
|
||||
],
|
||||
"time": "2017-11-15T23:40:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "erusev/parsedown",
|
||||
"version": "1.7.1",
|
||||
|
@ -613,60 +724,6 @@
|
|||
],
|
||||
"time": "2015-06-14T21:17:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/lexer",
|
||||
"version": "v1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/lexer.git",
|
||||
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c",
|
||||
"reference": "83893c552fd2045dd78aef794c31e694c37c0b8c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Lexer\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"lexer",
|
||||
"parser"
|
||||
],
|
||||
"time": "2014-09-09T13:34:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v2.10.4",
|
||||
|
|
Loading…
Reference in New Issue