Adding new PHP versions on travis, cleaning old comments to a new document

This commit is contained in:
Eduardo Gulias Davis
2014-05-04 18:31:29 +02:00
parent 0964bfd101
commit c4354acc0e
5 changed files with 85 additions and 95 deletions
+4
View File
@@ -2,6 +2,10 @@ language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
before_script:
- wget http://getcomposer.org/composer.phar
+63
View File
@@ -0,0 +1,63 @@
Email length
------------
http://tools.ietf.org/html/rfc5321#section-4.1.2
Forward-path = Path
Path = "<" [ A-d-l ":" ] Mailbox ">"
http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3
http://tools.ietf.org/html/rfc1035#section-2.3.4
DNS
---
http://tools.ietf.org/html/rfc5321#section-2.3.5
Names that can
be resolved to MX RRs or address (i.e., A or AAAA) RRs (as discussed
in Section 5) are permitted, as are CNAME RRs whose targets can be
resolved, in turn, to MX or address RRs.
http://tools.ietf.org/html/rfc5321#section-5.1
The lookup first attempts to locate an MX record associated with the
name. If a CNAME record is found, the resulting name is processed as
if it were the initial name. ... If an empty list of MXs is returned,
the address is treated as if it was associated with an implicit MX
RR, with a preference of 0, pointing to that host.
is_email() author's note: We will regard the existence of a CNAME to be
sufficient evidence of the domain's existence. For performance reasons
we will not repeat the DNS lookup for the CNAME's target, but we will
raise a warning because we didn't immediately find an MX record.
Check for TLD addresses
-----------------------
TLD addresses are specifically allowed in RFC 5321 but they are
unusual to say the least. We will allocate a separate
status to these addresses on the basis that they are more likely
to be typos than genuine addresses (unless we've already
established that the domain does have an MX record)
http://tools.ietf.org/html/rfc5321#section-2.3.5
In the case
of a top-level domain used by itself in an email address, a single
string is used without any dots. This makes the requirement,
described in more detail below, that only fully-qualified domain
names appear in SMTP transactions on the public Internet,
particularly important where top-level domains are involved.
TLD format
----------
The format of TLDs has changed a number of times. The standards
used by IANA have been largely ignored by ICANN, leading to
confusion over the standards being followed. These are not defined
anywhere, except as a general component of a DNS host name (a label).
However, this could potentially lead to 123.123.123.123 being a
valid DNS name (rather than an IP address) and thereby creating
an ambiguity. The most authoritative statement on TLD formats that
the author can find is in a (rejected!) erratum to RFC 1123
submitted by John Klensin, the author of RFC 5321:
http://www.rfc-editor.org/errata_search.php?rfc=1123&eid=1353
However, a valid host name can never have the dotted-decimal
form #.#.#.#, since this change does not permit the highest-level
component label to start with a digit even if it is not all-numeric.
+2 -5
View File
@@ -73,11 +73,8 @@ class EmailLexer extends AbstractLexer
protected $previous;
/**
* find
*
* @param mixed $type
*
* @throws UnexpectedValueException
* @param $type
* @throws \UnexpectedValueException
*/
public function find($type)
{
+3 -13
View File
@@ -19,11 +19,9 @@ class EmailParser
}
/**
* parse
*
* @param string $str
*
* @param $str
* @return array
* @throws \InvalidArgumentException
*/
public function parse($str)
{
@@ -38,13 +36,6 @@ class EmailParser
$parts = explode('@', $str);
if (strlen($parts[0] . '@' . $this->domainPart) > 254) {
// http://tools.ietf.org/html/rfc5321#section-4.1.2
// Forward-path = Path
//
// Path = "<" [ A-d-l ":" ] Mailbox ">"
//
// http://tools.ietf.org/html/rfc5321#section-4.5.3.1.3
// http://tools.ietf.org/html/rfc1035#section-2.3.4
$this->warnings[] = EmailValidator::RFC5322_TOOLONG;
}
@@ -391,9 +382,8 @@ class EmailParser
}
/**
* parseComments
*
* @return string the the comment
* @throws \InvalidArgumentException
*/
private function parseComments()
{
+13 -77
View File
@@ -9,7 +9,6 @@ namespace Egulias\EmailValidator;
*/
class EmailValidator
{
// Address is invalid for any purpose
const ERR_CONSECUTIVEATS = 128;
const ERR_EXPECTING_DTEXT = 129;
const ERR_NOLOCALPART = 130;
@@ -88,6 +87,7 @@ class EmailValidator
return false;
}
$dns = false;
if ($checkDNS) {
$dns = $this->checkDNS();
}
@@ -101,8 +101,6 @@ class EmailValidator
}
/**
* hasWarnings
*
* @return boolean
*/
public function hasWarnings()
@@ -111,8 +109,6 @@ class EmailValidator
}
/**
* getWarnings
*
* @return array
*/
public function getWarnings()
@@ -121,8 +117,6 @@ class EmailValidator
}
/**
* getError
*
* @return string
*/
public function getError()
@@ -131,8 +125,6 @@ class EmailValidator
}
/**
* setThreshols
*
* @param int $threshold
*
* @return EmailValidator
@@ -145,8 +137,6 @@ class EmailValidator
}
/**
* getThreshold
*
* @return int
*/
public function getThreshold()
@@ -164,79 +154,25 @@ class EmailValidator
return $checked;
}
// http://tools.ietf.org/html/rfc5321#section-2.3.5
// Names that can
// be resolved to MX RRs or address (i.e., A or AAAA) RRs (as discussed
// in Section 5) are permitted, as are CNAME RRs whose targets can be
// resolved, in turn, to MX or address RRs.
//
// http://tools.ietf.org/html/rfc5321#section-5.1
// The lookup first attempts to locate an MX record associated with the
// name. If a CNAME record is found, the resulting name is processed as
// if it were the initial name. ... If an empty list of MXs is returned,
// the address is treated as if it was associated with an implicit MX
// RR, with a preference of 0, pointing to that host.
//
// is_email() author's note: We will regard the existence of a CNAME to be
// sufficient evidence of the domain's existence. For performance reasons
// we will not repeat the DNS lookup for the CNAME's target, but we will
// raise a warning because we didn't immediately find an MX record.
$result = checkdnsrr(trim($this->parser->getParsedDomainPart()), 'MX');
$checked = true;
if (!$result) {
// Domain can't be found in DNS
$this->warnings[] = self::DNSWARN_NO_RECORD;
$checked = false;
}
// Check for TLD addresses
// -----------------------
// TLD addresses are specifically allowed in RFC 5321 but they are
// unusual to say the least. We will allocate a separate
// status to these addresses on the basis that they are more likely
// to be typos than genuine addresses (unless we've already
// established that the domain does have an MX record)
//
// http://tools.ietf.org/html/rfc5321#section-2.3.5
// In the case
// of a top-level domain used by itself in an email address, a single
// string is used without any dots. This makes the requirement,
// described in more detail below, that only fully-qualified domain
// names appear in SMTP transactions on the public Internet,
// particularly important where top-level domains are involved.
//
// TLD format
// ----------
// The format of TLDs has changed a number of times. The standards
// used by IANA have been largely ignored by ICANN, leading to
// confusion over the standards being followed. These are not defined
// anywhere, except as a general component of a DNS host name (a label).
// However, this could potentially lead to 123.123.123.123 being a
// valid DNS name (rather than an IP address) and thereby creating
// an ambiguity. The most authoritative statement on TLD formats that
// the author can find is in a (rejected!) erratum to RFC 1123
// submitted by John Klensin, the author of RFC 5321:
//
// http://www.rfc-editor.org/errata_search.php?rfc=1123&eid=1353
// However, a valid host name can never have the dotted-decimal
// form #.#.#.#, since this change does not permit the highest-level
// component label to start with a digit even if it is not all-numeric.
if (!$checked && (!in_array(self::DNSWARN_NO_RECORD, $this->warnings) &&
!in_array(self::DNSWARN_NO_MX_RECORD, $this->warnings))
) {
if (in_array($this->warnings, RFC5322_DOMAINLITERAL)) {
$this->warnings[] = self::RFC5321_TLD;
}
//if (isset($this->atomList[self::COMPONENT_DOMAIN][$this->elementCount][0]) &&
// is_numeric($this->atomList[self::COMPONENT_DOMAIN][$this->elementCount][0])
//) {
// $this->warnings[] = self::RFC5321_TLDNUMERIC;
//}
$this->addTLDWarnings();
}
return $checked;
}
public function addTLDWarnings()
{
if (!in_array(self::DNSWARN_NO_RECORD, $this->warnings) &&
!in_array(self::DNSWARN_NO_MX_RECORD, $this->warnings) &&
in_array(self::RFC5322_DOMAINLITERAL, $this->warnings)
) {
$this->warnings[] = self::RFC5321_TLD;
}
}
}