Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
070bd962
Commit
070bd962
authored
Nov 20, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed checkPort feature from email validator
fixes #1246
parent
45d92f1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
26 deletions
+2
-26
EmailValidator.php
framework/yii/validators/EmailValidator.php
+2
-26
No files found.
framework/yii/validators/EmailValidator.php
View file @
070bd962
...
...
@@ -41,25 +41,9 @@ class EmailValidator extends Validator
* @var boolean whether to check whether the emails domain exists and has either an A or MX record.
* Be aware of the fact that this check can fail due to temporary DNS problems even if the email address is
* valid and an email would be deliverable. Defaults to false.
* @see dnsMessage
*/
public
$checkDNS
=
false
;
/**
* @var string the error message to display when the domain of the email does not exist.
* It may contain the following placeholders which will be replaced accordingly by the validator:
*
* - `{attribute}`: the label of the attribute being validated
* - `{value}`: the value of the attribute being validated
*
* @see checkDNS
*/
public
$dnsMessage
;
/**
* @var boolean whether to check port 25 for the email address.
* Defaults to false.
*/
public
$checkPort
=
false
;
/**
* @var boolean whether validation process should take into account IDN (internationalized domain
* names). Defaults to false meaning that validation of emails containing IDN will always fail.
* Note that in order to use IDN validation you have to install and enable `intl` PHP extension,
...
...
@@ -80,9 +64,6 @@ class EmailValidator extends Validator
if
(
$this
->
message
===
null
)
{
$this
->
message
=
Yii
::
t
(
'yii'
,
'{attribute} is not a valid email address.'
);
}
if
(
$this
->
dnsMessage
===
null
)
{
$this
->
dnsMessage
=
Yii
::
t
(
'yii'
,
'The domain of this email address does not seem to exist.'
);
}
}
/**
...
...
@@ -118,13 +99,8 @@ class EmailValidator extends Validator
$value
=
$matches
[
1
]
.
idn_to_ascii
(
$matches
[
2
])
.
'@'
.
idn_to_ascii
(
$domain
)
.
$matches
[
4
];
}
$valid
=
preg_match
(
$this
->
pattern
,
$value
)
||
$this
->
allowName
&&
preg_match
(
$this
->
fullPattern
,
$value
);
if
(
$valid
)
{
if
(
$this
->
checkDNS
)
{
$valid
=
checkdnsrr
(
$domain
,
'MX'
)
||
checkdnsrr
(
$domain
,
'A'
);
}
if
(
$valid
&&
$this
->
checkPort
&&
function_exists
(
'fsockopen'
))
{
$valid
=
fsockopen
(
$domain
,
25
)
!==
false
;
}
if
(
$valid
&&
$this
->
checkDNS
)
{
$valid
=
checkdnsrr
(
$domain
,
'MX'
)
||
checkdnsrr
(
$domain
,
'A'
);
}
return
$valid
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment