If this is your first visit, check our documentation. To post, register or login.
Forums / Code Matters / Bug Reports / [Bogus, not a bug] zen_validate_email doesn't require a period

[Bogus, not a bug] zen_validate_email doesn't require a period

Locked

Started by numinix on 9 Nov 2012, 8:38 PM · Views: 1,305

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
9 Nov 2012, 8:38 PM
#1
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Location:
Vancouver, Canada
Posts:
1,573
Plugin Contributions:
60

Post #1 by numinix

the function zen_validate_email will properly return false if the @ symbol is missing. But it will return true if the period is missing.

For example, this would be considered a valid email according to that function:

askjfhsdkh@jkhsdkhsdfhcom

9 Nov 2012, 9:34 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,151
Plugin Contributions:
56

Post #2 by lat9

Are there other "non-period" sites other than localhost that should be considered valid?

10 Nov 2012, 2:11 PM
#3
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Post #3 by rodg

lat9:

Are there other "non-period" sites other than localhost that should be considered valid?

Yes. Any host on any given local network. IOW: anyhost@localdomain

localhost and localhost@localdomain are a special case in that they will always resolve to 127.0.0.1

'localdomain' need not be a literal. It could be 'mynet', 'localnet', 'coca-cola', etc, etc.....

This means something like bob@coca-cola is a perfectly valid address (albeit, not accessible from the Internet).

Does this adequately answer the question?

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

11 Nov 2012, 2:50 AM
#4
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Location:
Vancouver, Canada
Posts:
1,573
Plugin Contributions:
60

Post #4 by numinix

Why would a customer need to have something emailed to an address that is not accessible via the internet? I understand that you may need that for testing purposes, but in the real world we need a function that will stop people from registering with an invalid email account. Perhaps the Zen Cart devs could have a configuration controller for if the store is being run on a localhost to allow email addresses without periods, otherwise require it.

11 Nov 2012, 7:07 AM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Post #5 by rodg

numinix:

Why would a customer need to have something emailed to an address that is not accessible via the internet?

They wouldn't, but that has nothing to do with the question "Are there other non-period sites other than localhost that should be considered valid?"

numinix:

I understand that you may need that for testing purposes, but in the real world we need a function that will stop people from registering with an invalid email account.

Easier said than done. Who's to say whether '[email protected]' is a valid email address or not, unless you send a message to that address AND get a valid response. (it could be a black hole or honeypot).

numinix:

Perhaps the Zen Cart devs could have a configuration controller for if the store is being run on a localhost to allow email addresses without periods, otherwise require it.

Actually I am a little surprised that ZenCart doesn't (apparently) check to ensure that a supplied email address adheres to the [email protected] format anyway, and personally I don't see a need to make this any different even for local testing, so in short I'm in agreement with you here, there probably should be a check for the period.

In theory, this could already be the case, but if the period isn't 'escaped' before testing it will be considered a 'wild card' (It's a *nix thing) which could explain why "askjfhsdkh@jkhsdkhsdfhcom" returns true.

I (or someone) will need to take a look at the code to see exactly what the situation is.
It is also possible that the zencart devs don't check for this for some other reason.. (Who knows what goes on inside the mind of a programmer) <grin>

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

14 Nov 2012, 3:09 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #6 by drbyte

numinix:

the function zen_validate_email will properly return false if the @ symbol is missing. But it will return true if the period is missing.

For example, this would be considered a valid email according to that function:

askjfhsdkh@jkhsdkhsdfhcom

Sorry, I can't replicate this situation you mention, using v1.5.1 code. Both in unit tests and in actual live website tests, such as creating a customer account using askjfhsdkh@jkhsdkhsdfhcom (your suggestion) or missingDot@com (one matching test case in our unit tests) for the email address.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

15 Nov 2012, 12:26 AM
#7
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Location:
Vancouver, Canada
Posts:
1,573
Plugin Contributions:
60

Post #7 by numinix

DrByte,

I'm not testing by registering. I'm just giving the function zen_validate_email an email address without a period and as long as it has the @ symbol, it seems to validate. It doesn't require the period but it does accept it as a valid character.

16 Nov 2012, 9:00 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #8 by drbyte

Here's the unit test that shows the validation to work properly, by simply calling zen_validate_email() with a bunch of predefined patterns good and bad:
https://github.com/zencart/zencart/blob/v160/testFramework/unittests/testTestCase.php
You can see that yours is the same as the test case of missingDot@com

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Nov 2012, 2:13 AM
#9
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Location:
Vancouver, Canada
Posts:
1,573
Plugin Contributions:
60

Post #9 by numinix

Yes, you are right. Not a bug. Sorry about the false alarm. You can close this topic.