Compare commits

...

12 Commits

Author SHA1 Message Date
Stefan Grootscholten d42c8731f0 Fix issue that local part parser uses remaining code from lexer (#409)
Without this fix the added test will output

1) Egulias\EmailValidator\Tests\EmailValidator\EmailParserTest::testMultipleEmailAddresses
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'another-local-part'
+'some-random-but-large-domain-part.example.comanother-local-part'
2025-03-06 23:45:56 +01:00
Eduardo Gulias Davis 515346048d Different strategy 2024-12-31 16:29:41 +01:00
Eduardo Gulias Davis 4fc3f5c419 Different strategy 2024-12-31 16:26:39 +01:00
Eduardo Gulias Davis 7dc3b8de4c Coverage path (#401)
* coverage path

* Use different action
2024-12-31 16:15:01 +01:00
Cari D. Burstein 3bd9c8c802 Update NoDNSRecord.php (#395)
Fixed typo in No DNS Record reason
2024-12-31 15:41:19 +01:00
Eduardo Gulias Davis 8be1dae097 Polish (#400)
* Polish

* polish

* improve workflow

* Fix action usage

* polish

* polish
2024-12-31 15:39:18 +01:00
Eduardo Gulias Davis dcf8f79c41 polish 2024-12-27 23:41:39 +01:00
Eduardo Gulias Davis e30356b45e Fix action usage 2024-12-27 23:22:30 +01:00
Eduardo Gulias Davis 229560066e improve workflow 2024-12-27 23:11:08 +01:00
Eduardo Gulias Davis 1ed7ade52c Update to recommended two workflows for secure secret when uploadin (#399)
* Update to recommended two workflows for secure secret when uploadin

* Making depenant workflow work
2024-12-27 22:52:06 +01:00
Eduardo Gulias Davis 793eb01a3f Fix for secrets on PRs 2024-12-27 20:22:03 +01:00
Eduardo Gulias Davis 32b52d9e08 Test for #317 (#397) 2024-12-27 20:21:18 +01:00
9 changed files with 63 additions and 20 deletions
-1
View File
@@ -3,7 +3,6 @@ name: static analysis
on: on:
push: push:
branches: branches:
- master
- '*.x' - '*.x'
pull_request: pull_request:
+1 -11
View File
@@ -1,13 +1,10 @@
name: build name: unit-tests
on: on:
push: push:
branches: branches:
- master
- '*.x' - '*.x'
pull_request: pull_request:
schedule:
- cron: '0 0 * * *'
jobs: jobs:
tests: tests:
@@ -48,13 +45,6 @@ jobs:
- name: Execute tests - name: Execute tests
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --exclude-group flaky run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --exclude-group flaky
- name: Coverage
if: ${{ matrix.php == '8.1' && matrix.deps == 'lowest' }}
shell: bash
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r build/logs/clover.xml
- name: Store artifacts - name: Store artifacts
if: ${{ matrix.php == '8.1' && matrix.deps == 'lowest' }} if: ${{ matrix.php == '8.1' && matrix.deps == 'lowest' }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
+33
View File
@@ -0,0 +1,33 @@
name: upload-coverage-to-codacy
on:
workflow_run:
workflows: ["unit-tests"]
types:
- completed
jobs:
upload:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
strategy:
fail-fast: true
name: upload-coverage
steps:
- name: Setup logs directory
run: mkdir -p build/coverage
- name: Download clover.xml artifact
uses: dawidd6/action-download-artifact@v7
with:
workflow: tests.yml
name: clover.xml
path: build/coverage
- name: Upload Coverage to Codacy
shell: bash
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r build/coverage/clover.xml
+2 -2
View File
@@ -109,7 +109,6 @@ Validations not present in the RFCs
1. [SpoofCheckValidation](/src/Validation/Extra/SpoofCheckValidation.php): 1. [SpoofCheckValidation](/src/Validation/Extra/SpoofCheckValidation.php):
Will check for multi-utf-8 chars that can signal an erroneous email name. Will check for multi-utf-8 chars that can signal an erroneous email name.
### How to extend ### How to extend
It's easy! You just need to implement It's easy! You just need to implement
@@ -126,7 +125,8 @@ Is short and simple and will help a lot.
(You can find current contributors (You can find current contributors
[here](https://github.com/egulias/EmailValidator/graphs/contributors)) [here](https://github.com/egulias/EmailValidator/graphs/contributors))
As this is a port from another library and work, here are other people related to the previous one: As this is a port from another library and work, here are other people related
to the previous one:
* Ricard Clau [@ricardclau](https://github.com/ricardclau): * Ricard Clau [@ricardclau](https://github.com/ricardclau):
Performance against PHP built-in filter_var (v2 and earlier) Performance against PHP built-in filter_var (v2 and earlier)
+1
View File
@@ -34,6 +34,7 @@ class LocalPart extends PartParser
public function parse(): Result public function parse(): Result
{ {
$this->lexer->clearRecorded();
$this->lexer->startRecording(); $this->lexer->startRecording();
while (!$this->lexer->current->isA(EmailLexer::S_AT) && !$this->lexer->current->isA(EmailLexer::S_EMPTY)) { while (!$this->lexer->current->isA(EmailLexer::S_AT) && !$this->lexer->current->isA(EmailLexer::S_EMPTY)) {
+1 -1
View File
@@ -11,6 +11,6 @@ class NoDNSRecord implements Reason
public function description() : string public function description() : string
{ {
return 'No MX or A DSN record was found for this email'; return 'No MX or A DNS record was found for this email';
} }
} }
+4
View File
@@ -6,22 +6,26 @@ interface Result
{ {
/** /**
* Is validation result valid? * Is validation result valid?
*
*/ */
public function isValid(): bool; public function isValid(): bool;
/** /**
* Is validation result invalid? * Is validation result invalid?
* Usually the inverse of isValid() * Usually the inverse of isValid()
*
*/ */
public function isInvalid(): bool; public function isInvalid(): bool;
/** /**
* Short description of the result, human readable. * Short description of the result, human readable.
*
*/ */
public function description(): string; public function description(): string;
/** /**
* Code for user land to act upon. * Code for user land to act upon.
*
*/ */
public function code(): int; public function code(): int;
} }
+14
View File
@@ -28,4 +28,18 @@ class EmailParserTest extends TestCase
$this->assertEquals($local, $parser->getLocalPart()); $this->assertEquals($local, $parser->getLocalPart());
$this->assertEquals($domain, $parser->getDomainPart()); $this->assertEquals($domain, $parser->getDomainPart());
} }
public function testMultipleEmailAddresses()
{
$parser = new EmailParser(new EmailLexer());
$parser->parse('some-local-part@some-random-but-large-domain-part.example.com');
$this->assertSame('some-local-part', $parser->getLocalPart());
$this->assertSame('some-random-but-large-domain-part.example.com', $parser->getDomainPart());
$parser->parse('another-local-part@another.example.com');
$this->assertSame('another-local-part', $parser->getLocalPart());
$this->assertSame('another.example.com', $parser->getDomainPart());
}
} }
@@ -150,6 +150,8 @@ class RFCValidationTest extends TestCase
['\r\n \r\n test@iana.org'], ['\r\n \r\n test@iana.org'],
['test;123@foobar.com'], ['test;123@foobar.com'],
['examp║le@symfony.com'], ['examp║le@symfony.com'],
['example@invalid-.domain.com'],
['example@-invalid.com'],
['0'], ['0'],
[0], [0],
]; ];