User tests: Successful: Unsuccessful:
Pull Request for Issue #9500.
I've added + instead of * in the regexp, so now after setting the tld param at least one domain is required in the e-mail.
The regexps was the same so the tld param was not working for e-mail validation.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Libraries |
@infograf768 - ok, but what is the sense of existence for the tld param? As you can see before my change the regex property contains exactly the same regular expression. I thought that tld option enables a check for the tld domain in the e-mail.
@dziudek I agree with you, this change is valid. If the field is set to check for a TLD it should check for a TLD. Since this file has been updated in the meantime, can you check if it works with the current staging version of Joomla?
@roland-d - as I see the following change: 98c48ee doesn't fix the issue - I've checked it in http://regexr.com/
for test case:
test@gmail
test@gmail.com
The current regexp accepts both mails, when it should accept only the second one. And my change - replacing *$
into +$
at the end still helps :)
Also what @infograf768 wrote above is right, so both cases are valid:
test@gmail
test@gmail.com
@dgt41 No, I disagree that both cases are valid. If the XML definition states that the TLD is required we must check for it. If the TLD requirement is not set, then we should allow both cases.
As for the W3C query, yes it is valid for both cases but not if the TLD is required.
@roland-d so how do you set the XML to require a TLD?
<field name="email" type="email"
label="JGLOBAL_EMAIL"
description="COM_ADMIN_USER_FIELD_EMAIL_DESC"
required="true"
size="30"
class="inputbox"
validate="email" />
Never mind I was using the documentation which doesn;t mention the tld... Nice!
@dgt41 Check this line:
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/form/rule/email.php#L56
You add the element tld to the XML field.
Travis isnt happy with this ;(
The failure is testing that test3@localhost
passes the check with the tld
attribute set and with this patch it's not. If I'm glancing this over correctly, the change mandates a domain.tld
structure. So if that's the case, this data set needs to be changed so that false is the expected result since this won't pass since it's missing a TLD. Or if localhost
is supposed to be valid on its own even with the tld
attribute set then the code needs to be adjusted to account for this special case.
@mbabker Yes I came to the same conclusion, just don't know how to change the dataset because the email test3@localhost has a false value set in the dataset.
If you require a tld by specifying that in the XML then localhost shouldn't be allowed I guess unless we decide it's an exception to the rule.
I don't think @localhost should be true in the last tld test, looks like there was a bug before.
So only this line needs changes, for the tests to pass.
@yvesh Thanks for that. I don't know why but that line had a false argument when I was looking at it yesterday. That got me confused. No idea what I was looking at then :)
@dziudek Can you change the line mentioned by Yvesh and replace true with false and commit that change. We can then see if Travis passes. Thanks.
Category | Libraries | ⇒ | Libraries Unit Tests |
Labels |
Added:
?
|
How to test?
I have tested it, now works fine
I have tested this item
To test this, do the following:
1. Modify the file components/com_users/models/forms/registration.xml by adding this line to the email1 field tld="required"
or tld="tld"
both options work the same. This forces emails to have a TLD specified.
2. Try to register a user with an email me@example
3. Joomla will happily register this user
4. Apply the patch
5. Try to register a user with an email meagain@example
6. This will not be allowed and a message will be shown that the email address is invalid
7. Try to register the user with the mail meagain@example.com
8. User is now registered because a TLD exists.
I have tested this item
Registering a user without a TLD is possible before the patch despite requiring the TLD. After applying the patch an email without TLD cannot be registered if required.
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-08-29 17:30:30 |
Closed_By | ⇒ | rdeutz |
Tests don't work and for a good reason: this patch prevents mails of the type
maymail@localhost
The general result is: Address is valid for SMTP but has unusual elements
The specific diagnosis is: Address is valid but at a Top Level Domain
Here is the relevant passage from the email RFCs:
RFC 5321 section 2.3.5
http://tools.ietf.org/html/rfc5321#section-2.3.5