Closed (fixed)
Project:
Invisimail
Version:
6.x-1.2
Component:
Miscellaneous
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Sep 2009 at 20:25 UTC
Updated:
13 Dec 2010 at 23:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
oligog commentedtry to change line 112 to:
$domain = '(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9\-][a-zA-Z0-9\-]*[a-zA-Z0-9\-])\.?)+';I added the "\-" (without ") because there may be such a -character in a domain name...
& now it works!
The obfuscated e-mail still breaks the layout (i´ve to put it into the flow).
Comment #2
tiggr93 commentedConfirm this fix does work, although I used a different regex for validating full domains (first & last character of subdomain must be alpha-numeric, hyphens only allowed in between, also validates TLD):
$domain = '([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}';
Comment #3
dboulet commentedThanks for the code tiggr93, it also helped me with another issue I had where any word with the '@' symbol in it turned into a mailto link.
Comment #4
rkendall commentedGlad I spotted this issue before I noticed it as a problem on a site.
Wouldn't it be better to re-use a proven email/domain regex? While I'm glad of the suggested fix, I am left wondering what different issues it might throw up.
Some references:
http://code.iamcal.com/php/rfc822/
http://www.dominicsayers.com/isemail/
http://squiloople.com/2009/12/20/email-address-validation/
http://www.hm2k.com/posts/what-is-a-valid-email-address
http://fightingforalostcause.net/misc/2006/compare-email-regex.php
Comment #5
Crell commentedWell, "real" email address validation takes several pages of incomprehensible regex. I'm not doing that. :-) For one, it's horribly difficult to do. For another, I don't actually grok most regex. Email addresses are just a horrifically stupidly defined spec.
I've gone ahead and committed #3, as it does fix the problem mentioned here. I am planning on a Drupal 7 port later this week that will likely involve some restructuring of the code. It is possible that we'll be able to switch to using a PHP-native ext/filter pattern for it, but I'm not sure. Definitely I am not going to try and break the Drupal 6 version at this point. :-)
Thanks, dboulet!
Comment #6
MRushton commentedCrell, email address regular expressions are not that complicated if you simply break it into individual components. I've done so in the article linked to by rkendall (http://squiloople.com/2009/12/20/email-address-validation/). And it's certainly not pages long:
To validate according to RFC 5321, allowing dot-atom and quoted string local parts, and domain name and domain literal domains, a regular expression of just 381 characters is needed:
/^(?>([!#-\'*+\/-9=?^-~-]+)(?>\.(?1))*|"(?>[ !#-\[\]-~]|\\\[ -~])*")@(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?2)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?3)){7}|(?!(?:.*[a-f0-9][:\]]){8,})((?3)(?>:(?3)){0,6})?::(?4)?))|(?>(?>IPv6:(?>(?3)(?>:(?3)){5}:|(?!(?:.*[a-f0-9]:){6,})(?5)?::(?>((?3)(?>:(?3)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?6)){3}))\])$/iDTo validate according to RFC 5322, allowing dot-atom, quoted string, and obsolete local parts, domain name and domain literal domains, and comments and folding white spaces, a regular expression of just 583 characters is needed:
/^((?>(?>(?>((?>[ ]+(?>\x0D\x0A[ ]+)*)?)(\((?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>(?1)\.(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isDIndeed, PHP's native function
filter_varuses an older version of the first regular expression here. I've updated it since then. Personally, I think it's more useful than the second. Comments and folding white spaces are unnecessary, and even a nuisance. If you want even more functionality, perhaps you'd be interested in using the following class, also provided in my article, but copied here nonetheless in case you don't want to load a new page:Comment #7
Crell commentedMRushton: Please do not keep editing and resaving your comment, or whatever it is that's causing it to show up as "new" again every day. That is very rude. The regex for invisimail is not changing for Drupal 6. It will not change for Drupal 7 either until and unless we have a test suite in place and viable test cases that fail without changing it. This issue is closed.