Compare commits

...

5 Commits

Author SHA1 Message Date
Eduardo Gulias Davis ca90a3291e Cleanup 2020-11-14 16:56:27 +01:00
Eduardo Gulias Davis d04083e28b Allow people to show appreciation :) 2020-11-14 16:51:45 +01:00
Eduardo Gulias Davis db476db25e fix #272 2020-11-14 16:27:34 +01:00
Eduardo Gulias Davis d37d5a361e fix #255, fix #130 (#270) 2020-11-07 16:12:21 +01:00
David 5fa792ad18 Email addresses with single quote should not be valid (#268)
* Fixes issue for email addresses with single quote in domain part
* specify version in cli for older php versions

Co-authored-by: Eduardo Gulias Davis <eduardomgulias@gmail.com>
2020-10-31 21:37:35 +01:00
10 changed files with 28 additions and 12 deletions
+3
View File
@@ -0,0 +1,3 @@
# Thanks!
github: [egulias]
+1
View File
@@ -1,4 +1,5 @@
.idea .idea
.vscode
composer.lock composer.lock
report/ report/
vendor/ vendor/
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -31,7 +31,7 @@ matrix:
install: install:
- if [ "$deps" = "low" ]; then composer update --prefer-lowest; else composer install; fi - if [ "$deps" = "low" ]; then composer update --prefer-lowest; else composer install; fi
- if [ "$psalm" = "yes" ]; then composer require --dev vimeo/psalm; fi - if [ "$psalm" = "yes" ]; then composer require --dev vimeo/psalm:3.18.2; fi
before_script: before_script:
- mkdir -p build/logs - mkdir -p build/logs
@@ -42,3 +42,4 @@ script:
after_script: after_script:
- php vendor/bin/coveralls - php vendor/bin/coveralls
+9 -10
View File
@@ -42,16 +42,14 @@ $validator->isValid("example@example.com", new RFCValidation()); //true
### Available validations ### ### Available validations ###
1. [RFCValidation](/src/Validation/RFCValidation.php) 1. [RFCValidation](/src/Validation/RFCValidation.php): Standard RFC-like email validation.
2. [NoRFCWarningsValidation](/src/Validation/NoRFCWarningsValidation.php) 2. [NoRFCWarningsValidation](/src/Validation/NoRFCWarningsValidation.php): RFC-like validation that will fail when warnings* are found.
3. [DNSCheckValidation](/src/Validation/DNSCheckValidation.php) 3. [DNSCheckValidation](/src/Validation/DNSCheckValidation.php): Will check if there are DNS records that signal that the server accepts emails. This does not entails that the email exists.
4. [SpoofCheckValidation](/src/Validation/SpoofCheckValidation.php) 4. [SpoofCheckValidation](/src/Validation/SpoofCheckValidation.php): Will check for multi-utf-8 chars that can signal an erroneous email name.
5. [MultipleValidationWithAnd](/src/Validation/MultipleValidationWithAnd.php) 5. [MultipleValidationWithAnd](/src/Validation/MultipleValidationWithAnd.php): It is a validation that operates over other validations performing a logical and (&&) over the result of each validation.
6. [Your own validation](#how-to-extend) 6. [Your own validation](#how-to-extend): You can extend the library behaviour by implementing your own validations.
`MultipleValidationWithAnd` *warnings: Warnings are deviations from the RFC that in a broader interpretation are acceptded.
It is a validation that operates over other validations performing a logical and (&&) over the result of each validation.
```php ```php
<?php <?php
@@ -66,7 +64,8 @@ $multipleValidations = new MultipleValidationWithAnd([
new RFCValidation(), new RFCValidation(),
new DNSCheckValidation() new DNSCheckValidation()
]); ]);
$validator->isValid("example@example.com", $multipleValidations); //true //ietf.org has MX records signaling a server with email capabilites
$validator->isValid("example@ietf.org", $multipleValidations); //true
``` ```
### How to extend ### ### How to extend ###
+4
View File
@@ -13,6 +13,8 @@ class EmailLexer extends AbstractLexer
const S_BACKSLASH = 92; const S_BACKSLASH = 92;
const S_DOT = 46; const S_DOT = 46;
const S_DQUOTE = 34; const S_DQUOTE = 34;
const S_SQUOTE = 39;
const S_BACKTICK = 96;
const S_OPENPARENTHESIS = 49; const S_OPENPARENTHESIS = 49;
const S_CLOSEPARENTHESIS = 261; const S_CLOSEPARENTHESIS = 261;
const S_OPENBRACKET = 262; const S_OPENBRACKET = 262;
@@ -58,6 +60,8 @@ class EmailLexer extends AbstractLexer
'/' => self::S_SLASH, '/' => self::S_SLASH,
',' => self::S_COMMA, ',' => self::S_COMMA,
'.' => self::S_DOT, '.' => self::S_DOT,
"'" => self::S_SQUOTE,
"`" => self::S_BACKTICK,
'"' => self::S_DQUOTE, '"' => self::S_DQUOTE,
'-' => self::S_HYPHEN, '-' => self::S_HYPHEN,
'::' => self::S_DOUBLECOLON, '::' => self::S_DOUBLECOLON,
+2
View File
@@ -335,6 +335,8 @@ class DomainPart extends Parser
{ {
$invalidDomainTokens = array( $invalidDomainTokens = array(
EmailLexer::S_DQUOTE => true, EmailLexer::S_DQUOTE => true,
EmailLexer::S_SQUOTE => true,
EmailLexer::S_BACKTICK => true,
EmailLexer::S_SEMICOLON => true, EmailLexer::S_SEMICOLON => true,
EmailLexer::S_GREATERTHAN => true, EmailLexer::S_GREATERTHAN => true,
EmailLexer::S_LOWERTHAN => true, EmailLexer::S_LOWERTHAN => true,
+1 -1
View File
@@ -120,7 +120,7 @@ class DNSCheckValidation implements EmailValidation
// No MX, A or AAAA DNS records // No MX, A or AAAA DNS records
if (empty($dnsRecords) || !$dnsRecords) { if (empty($dnsRecords)) {
$this->error = new NoDNSRecord(); $this->error = new NoDNSRecord();
return false; return false;
} }
+2
View File
@@ -138,6 +138,8 @@ class EmailLexerTests extends TestCase
array(":", EmailLexer::S_COLON), array(":", EmailLexer::S_COLON),
array(".", EmailLexer::S_DOT), array(".", EmailLexer::S_DOT),
array("\"", EmailLexer::S_DQUOTE), array("\"", EmailLexer::S_DQUOTE),
array("'", EmailLexer::S_SQUOTE),
array("`", EmailLexer::S_BACKTICK),
array("-", EmailLexer::S_HYPHEN), array("-", EmailLexer::S_HYPHEN),
array("\\", EmailLexer::S_BACKSLASH), array("\\", EmailLexer::S_BACKSLASH),
array("/", EmailLexer::S_SLASH), array("/", EmailLexer::S_SLASH),
@@ -168,6 +168,8 @@ class RFCValidationTest extends TestCase
['test@email{'], ['test@email{'],
['test@ '], ['test@ '],
['test@example.com []'], ['test@example.com []'],
["test@example.com'"],
["test@exam`ple.com"],
]; ];
} }
@@ -212,6 +214,7 @@ class RFCValidationTest extends TestCase
[new CRNoLF(), "example@exa\rmple.co.uk"], [new CRNoLF(), "example@exa\rmple.co.uk"],
[new CRNoLF(), "example@[\r]"], [new CRNoLF(), "example@[\r]"],
[new CRNoLF(), "exam\rple@example.co.uk"], [new CRNoLF(), "exam\rple@example.co.uk"],
[new ExpectingATEXT(), "test@example.com'"],
]; ];
} }