|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of EC-CUBE |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* http://www.lockon.co.jp/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Eccube\Validator\EmailValidator; |
|
15
|
|
|
|
|
16
|
|
|
use Egulias\EmailValidator\EmailValidator; |
|
17
|
|
|
use Egulias\EmailValidator\Validation\EmailValidation; |
|
18
|
|
|
|
|
19
|
|
|
class NoRFCEmailValidator extends EmailValidator |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @param $email |
|
23
|
|
|
* @param EmailValidation $emailValidation |
|
24
|
|
|
* |
|
25
|
|
|
* @return bool |
|
26
|
|
|
*/ |
|
27
|
|
|
public function isValid($email, EmailValidation $emailValidation) |
|
28
|
|
|
{ |
|
29
|
|
|
|
|
30
|
|
|
$pattern = "/^[a-zA-Z0-9_\.@\+\?-]+$/i"; |
|
31
|
|
|
if (strlen($email) > 0 && !preg_match($pattern, $email)) { |
|
32
|
|
|
return false; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
$wsp = '[\x20\x09]'; |
|
36
|
|
|
$vchar = '[\x21-\x7e]'; |
|
37
|
|
|
$quoted_pair = "\\\\(?:$vchar|$wsp)"; |
|
38
|
|
|
$qtext = '[\x21\x23-\x5b\x5d-\x7e]'; |
|
39
|
|
|
$qcontent = "(?:$qtext|$quoted_pair)"; |
|
40
|
|
|
$quoted_string = "\"$qcontent*\""; |
|
41
|
|
|
$atext = '[a-zA-Z0-9!#$%&\'*+\-\/\=?^_`{|}~]'; |
|
42
|
|
|
$dot_atom = "$atext+(?:[.]$atext+)*"; |
|
43
|
|
|
$domain = $dot_atom; |
|
44
|
|
|
$dot_atom_loose = "$atext+(?:[.]|$atext)*"; |
|
45
|
|
|
$local_part_loose = "(?:$dot_atom_loose|$quoted_string)"; |
|
46
|
|
|
$addr_spec_loose = "{$local_part_loose}[@]$domain"; |
|
47
|
|
|
|
|
48
|
|
|
// 携帯メールアドレス用に、..や.@を許容する。 |
|
49
|
|
|
$regexp = "/\A{$addr_spec_loose}\z/"; |
|
50
|
|
|
|
|
51
|
|
|
if (!preg_match($regexp, $email)) { |
|
52
|
|
|
return false; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
return true; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|