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
|
|
|
/** |
20
|
|
|
* SwiftMailerで使用するEmailのバリデータ. |
21
|
|
|
* |
22
|
|
|
* eccube_rfc_email_checkがfalseの際に, このバリデータが使用される. |
23
|
|
|
* 日本のキャリアメールで使用されていた, ..や.@の形式を許容します. |
24
|
|
|
*/ |
25
|
|
|
class NoRFCEmailValidator extends EmailValidator |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @param $email |
29
|
|
|
* @param EmailValidation|null $emailValidation |
30
|
|
|
* @return bool |
31
|
|
|
*/ |
32
|
|
|
public function isValid($email, EmailValidation $emailValidation = null) |
33
|
|
|
{ |
34
|
|
|
$wsp = '[\x20\x09]'; |
35
|
|
|
$vchar = '[\x21-\x7e]'; |
36
|
|
|
$quoted_pair = "\\\\(?:$vchar|$wsp)"; |
37
|
|
|
$qtext = '[\x21\x23-\x5b\x5d-\x7e]'; |
38
|
|
|
$qcontent = "(?:$qtext|$quoted_pair)"; |
39
|
|
|
$quoted_string = "\"$qcontent*\""; |
40
|
|
|
$atext = '[a-zA-Z0-9!#$%&\'*+\-\/\=?^_`{|}~]'; |
41
|
|
|
$dot_atom = "$atext+(?:[.]$atext+)*"; |
42
|
|
|
$domain = $dot_atom; |
43
|
|
|
$dot_atom_loose = "$atext+(?:[.]|$atext)*"; |
44
|
|
|
$local_part_loose = "(?:$dot_atom_loose|$quoted_string)"; |
45
|
|
|
$addr_spec_loose = "{$local_part_loose}[@]$domain"; |
46
|
|
|
|
47
|
|
|
// 携帯メールアドレス用に、..や.@を許容する。 |
48
|
|
|
$regexp = "/\A{$addr_spec_loose}\z/"; |
49
|
|
|
|
50
|
|
|
if (!preg_match($regexp, $email)) { |
51
|
|
|
return false; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return true; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|