Problem/Motivation
Split of symfony 2.5 (#2278353: Update to Symfony 2.5)
The validator API in symfony was rewritten from using filter_var():
filter_var('bob@example.com', FILTER_VALIDATE_EMAIL);
to either using a simple regex (not RFC compliant, but faster) or an external library: egulias/EmailValidator (which is slower but standard compliant).
Proposed resolution
All people on #2278353: Update to Symfony 2.5 (comment 31 and following) favored the standard compliant external library, let's get it into core.
Edit: just for historical accuracy because I can guarantee noone will actually read the linked issue, this is not true. #2278353-31: Update to Symfony 2.5 named three options, raised questions, #2278353-32: Update to Symfony 2.5 added more questions, #2278353-33: Update to Symfony 2.5 reminded that punycode needs to validate, #2278353-34: Update to Symfony 2.5 unilaterally decided to end the discussion and do this.
Edit: #2278353-79: Update to Symfony 2.5 votes to make this an optional upgrade by falling back onto filter_var() in an override class.
Email-validator ships with the standards which have non-proper line-endings, so git might complain.
Remaining tasks
User interface changes
API changes
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | email_validator-2313669-29.patch | 93.32 KB | hussainweb |
Comments
Comment #1
dawehnerComment #2
dawehnerComment #3
dawehnerThis time done properly ...
Comment #4
dawehnerLet's give it another try:
composer require egulias/email-validator 1.1.1Comment #5
effulgentsia commentedFor reference, this is the Symfony commit that started using this library: https://github.com/symfony/symfony/commit/3368630482c0f5f5c0ebaf08e64347....
Comment #6
dawehnerJust another ordinary reroll ... (looking forward to get rid of the vendor shipped with git)
I consider this as major now, given that it blocks a critical (we can't release with an old version of symfony which will not be supported quite fast).
Comment #7
dries commentedIdeally, this would be fixed in PHP but sadly, that is not a realistic expectation. It seems like a lot of extra code but in general, I prefer to add a library rather than having to subclass Symfony to change its behavior. I'm not thrilled with it but all things considered, I'm ok with adding this library.
Comment #8
dawehnerYeah it is a shame that a programming language dealing with basically just web is not capable to come up with proper implementations.
Me too, those kind of things are just non-trivial to get right.
The actual library (without tests, composer) is not bigger than 1k lines though.
Comment #9
effulgentsia commentedUnassigning Dries, since he answered in #7.
Comment #10
chx commentedEdit: nevermind.
Comment #11
sun+1 in general. PHP core always lacked behind reality, and any amount of PCRE is not able to reliably deal with advanced characteristics like IDNs, IPv6, etc.pp.
That said, I didn't really study the library's code, so I don't want to RTBC.
Lastly, it would be great to adjust our
.gitignoreto exclude:We really don't need all of those upstream tests in our repo at all.
Comment #12
dawehnerWhat I think we really want is to not include all those libraries at all in the first place. The tests itself
are a great source to understand how to use all the code the libraries provide.
Comment #13
chx commentedComment #14
pfrenssenUpdated patch to the newer 1.2.0 release of the library.
Comment #15
dawehner1.2 is certainly more sane
Comment #16
effulgentsia commentedHere's the relevant code from Symfony's upgrade to 2.5:
#7 answers that we don't want to override this class, but I'm sitting here at TCDrupal near alexpott and he's asking what would be wrong with just allowing the very permissive regex at the bottom to operate.
Comment #17
dawehnerI totally understand and struggled as well, why do we need 1000 lines of code to properly validate
a mail adress, given that noone really complained about filter_var()
Their idea is described good in one sentence (https://github.com/symfony/symfony/issues/1581#issuecomment-50854181)
The decision was to be either simple and (fully) non-strict or strict, and not half-ways, which would be the filter_var option.Once you use the really simple regex here you start to get problems as this is validation for mail adresses of actual users. Do we really want to just allow people
to make typos and then make it impossible for them to actually login, as their one-time mail was not sent out properly?
Comment #18
pfrenssenComment #19
dawehnerCurrently blocked on #2303673: Implement stackphp; cleanup handlePageCache() and preHandle()
Comment #20
effulgentsia commentedRe #19: why does this issue need to be blocked on that? What's the relationship between the two?
Comment #21
dawehnerWell, I just want to reduce the costs the community has to do for rerolls of various composer.json files.
If these changes are not totally in random order these costs can be reduced as they are known beforehand
Comment #24
dawehnerThis is just a reroll for now.
Comment #25
neclimdullink to comments
Comment #26
droplet commentedAlso the front-end HTML5 validation has diff results in diff browsers, therefore adding users programmatically may not pass frontend checking.
http://trac.webkit.org/browser/trunk/Source/WebCore/html/EmailInputType....
http://hg.mozilla.org/mozilla-central/file/805aff291ec2/content/html/con...
Comment #29
hussainwebRerolling... There were conflicts in the
composer.lockandcore/vendor/composer/installed.jsonfiles.Comment #30
cilefen commentedThis patch is holding up at least 2 criticals, so it is critical.
This patch is in-scope and does exactly what it says. It is agreed in the parent issue that this library is necessary to provide strict email address validation with Symfony 2.5+.
Comment #31
cilefen commentedSee #2278353-79: Update to Symfony 2.5: @dawehner @berdir and I discussed the email validation question on IRC and concluded that since valid_email_address() still exists and uses filter_var() then it makes no sense to have the validator class act differently. Because of that, I propose we add a new validator that overrides Symfony's that does filter_var().
This issue should be considered an upgrade to email validation.
Comment #32
fagoWhy not simply update valid_email_address() to use the constraint as well?
Comment #33
cilefen commented@fago Personally, I like that idea. We should do that. But I don't want Symfony 2.5 to depend on this issue.
Comment #34
effulgentsia commentedDries rejected #31 in #7.
The question that's left here is whether to add the library or do what alexpott asked about in #16 (I typed up the comment, but it was his question): use the fallback to the very permissive regex check in core, and allow contrib modules or sites that want the robust validation to add the library themselves.
I think #26 might be a good answer to not falling back to the very permissive regex: i.e., you could enter an address on one browser/device that will fail client-side validation on another one.
So, assigning this one to alexpott to see if that answers his question adequately, or if he wants to kick it back to us, or to Dries.
Comment #35
alexpottCommitted 8071855 and pushed to 8.0.x. Thanks!
Ran https://github.com/egulias/EmailValidator/blob/master/tests/egulias/Perf... considering this will not be run 100's of times per request.
Comment #37
cilefen commented#2343043: valid_email_address() should use egulias/EmailValidator and become deprecated