Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing SwiftMailer test after upgrade to v3 #282

Closed
driesvints opened this issue Jan 22, 2021 · 13 comments · Fixed by #290
Closed

Failing SwiftMailer test after upgrade to v3 #282

driesvints opened this issue Jan 22, 2021 · 13 comments · Fixed by #290

Comments

@driesvints
Copy link
Contributor

Hi all, I hope this is the right place to ask this question as I couldn't immediately find something in the contributing guidelines. Appreciating if anyone could answer a question I have about a failing SwiftMailer test after upgrading to v3.

I've tried patching SwiftMailer to v3 which mostly went super smooth and didn't require any code changes (thanks!). But one test is now failing for EmailValidator v3:

https://github.com/swiftmailer/swiftmailer/blob/master/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php#L118

With the following message:

1) Swift_Mime_Headers_IdentificationHeaderTest::testIdRightCanBeDotAtom
Swift_RfcComplianceException: Invalid ID given <a@b.c+&%$.d>

/Users/driesvints/Sites/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php:183
/Users/driesvints/Sites/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php:128
/Users/driesvints/Sites/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php:99
/Users/driesvints/Sites/swiftmailer/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php:118

The exception is being thrown here:

https://github.com/swiftmailer/swiftmailer/blob/master/lib/classes/Swift/Mime/Headers/IdentificationHeader.php#L183

I guess my main question is why a@b.c+&%$.d isn't a valid email address anymore in EmailValidator v3? I'm not very familiar with all of the rules from RFC 2822 so I don't immediately see what's wrong here.

@egulias
Copy link
Owner

egulias commented Jan 24, 2021

Hello @driesvints , it is the right place to ask!
The test is failing because v3 of the validator validates the domain part (after the @) against RFC1035 which is actually what is used in Real Life (r) and generated lots of confusion in user-land (as you can read in the changelog https://github.com/egulias/EmailValidator/blob/3.x/CHANGELOG.md#breacking-changes).
Now, the test is validating an "ID" from the header which can be an email address or any other thing. Similar to symfony/symfony#39685 , which used this validator's use of the more open definition for the domain part to validate other parts of the email (i.e: ID, address list, etc), which is also failing.

I'm working to add that into the next minor version (#195 ) , the challenge is to mix validations of different type of specs.
Meanwhile you can stick to 2.1 as I still give it maintenance.

Hope this helps to solve your question!

@driesvints
Copy link
Contributor Author

Hey @egulias thank you for the very thorough answer! I'll keep an eye out on that issue and the Symfony PR to see what they'll do. Nothing is urgent here. Thanks for your work! 👍

@cdjenkins
Copy link

cdjenkins commented Feb 4, 2021

I added swiftmailer ("swiftmailer/swiftmailer": "^6.0") to my composer.json. This installed version 2.1.25 of your library. Now one of my unit tests fails. Now $validator->assert('d@dcom'); should throw an exception, but now doesn't. Any ideas why?

@driesvints
Copy link
Contributor Author

@cdjenkins maybe best that you create a separate issue for that so this one stays at the topic on hand?

@egulias
Copy link
Owner

egulias commented Feb 7, 2021

Hi @cdjenkins , please open a new issue so we keep topics scoped. Happy to help you in the new one.

@cdjenkins
Copy link

will do

@cdjenkins
Copy link

added my concern as a new issue.

@egulias egulias reopened this Mar 7, 2021
@egulias
Copy link
Owner

egulias commented Mar 7, 2021

@driesvints Github did it's magic and closed it. v3.1 has been released, please close the issue once you fix Swiftmailer with the new version.
Thanks!

@driesvints
Copy link
Contributor Author

Hey @egulias. I have no idea how it's possible but the test fails again with the newly tagged v3.1.0.

1) Swift_Mime_Headers_IdentificationHeaderTest::testIdRightCanBeDotAtom
Swift_RfcComplianceException: Invalid ID given <a@b.c+&%$.d>

I see some extra commits have been added to the PR after I tested it. Did something from those break it again?

@driesvints
Copy link
Contributor Author

I tried again with the exact commit from before I tested and now the test is failing again. I have no idea why it was passing for me before... I'm sure I required the correct PR branch...

@driesvints
Copy link
Contributor Author

Nvm, false alarm. I forgot to make use of the new class. Everything's working now 😅 Sorry about that.

Thanks again for helping out here!

@driesvints
Copy link
Contributor Author

Here's the SwiftMailer PR: swiftmailer/swiftmailer#1334

fabpot added a commit to swiftmailer/swiftmailer that referenced this issue Mar 9, 2021
This PR was squashed before being merged into the 6.2-dev branch.

Discussion
----------

Egulias EmailValidator v3

<!-- Please fill in this template according to the PR you're about to submit. -->

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| Doc update?   | no
| BC breaks?    | no
| Deprecations? | no
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT

This PR implements egulias/email-validator v3. After some back an forth in egulias/EmailValidator#282 @egulias was so kind to provide a new EmailValidation that properly handles the test case of SwiftMailer's IdentificationHeader validation. `^3.1` is needed to make use of the new email validation. I've added a class check to use the old one when it isn't present for `^2.0`.

After merging and tagging this PR we can add support for EmailValidator v3 in Laravel. Let me know if you need anything else 👍

Commits
-------

0a6037a Egulias EmailValidator v3
@driesvints
Copy link
Contributor Author

PR was merged and released.

markovlatkovic added a commit to markovlatkovic/swiftmailer that referenced this issue May 24, 2024
This PR was squashed before being merged into the 6.2-dev branch.

Discussion
----------

Egulias EmailValidator v3

<!-- Please fill in this template according to the PR you're about to submit. -->

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| Doc update?   | no
| BC breaks?    | no
| Deprecations? | no
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT

This PR implements egulias/email-validator v3. After some back an forth in egulias/EmailValidator#282 @egulias was so kind to provide a new EmailValidation that properly handles the test case of SwiftMailer's IdentificationHeader validation. `^3.1` is needed to make use of the new email validation. I've added a class check to use the old one when it isn't present for `^2.0`.

After merging and tagging this PR we can add support for EmailValidator v3 in Laravel. Let me know if you need anything else 👍

Commits
-------

0a6037a Egulias EmailValidator v3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants