Re: [Evolution-hackers] mail address validation
That won't actually work (at least not very well). The Camel address decoding functions assume their input is supposed to be valid and so it will do whatever it has to do to make it work. It would have to be extremely broken for it to fail. What you'll probably have to do is write similar functionality that is much more strict in what it accepts. Jeff Roberto -MadBob- Guido wrote: I was re-working the patch at https://bugzilla.gnome.org/show_bug.cgi?id=213724 after reading the comment from Milan Crha (that I just now saw, with a pair of months of delay :-P ), but it is unclear to me now to validate a mail address using camel_*address_* functions. Here a little test I've done: // #include stdio.h #include camel/camel.h static void test (const gchar *address) { int ret; CamelInternetAddress *addr; addr = camel_internet_address_new (); ret = camel_address_decode (CAMEL_ADDRESS (addr), address); if (ret == -1) printf (%s: FAIL!\n, address); else printf (%s: OK\n, address); } int main () { g_type_init (); g_thread_init (NULL); test (madbob); test (2345678); test (mad...@example.org); exit (0); } // The test results always positive, with any string I submit, I'm sure I'm missing something but don't know what. Suggestions? Thanks :-) ___ Evolution-hackers mailing list Evolution-hackers@gnome.org http://mail.gnome.org/mailman/listinfo/evolution-hackers
Re: [Evolution-hackers] mail address validation
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey :-) On 21.01.2010 19:17, Roberto -MadBob- Guido wrote: In the first version of the patch ( http://bugzilla-attachments.gnome.org/attachment.cgi?id=146701 ) I've provided a routine built on regular expressions (regcomp() and regexec()). Opinions about that? Thanks for you contribution. However, it is way too strict. It misses all the interesting characters that are allowed in the local part, i.e.: ! $ * - = ^ ` | ~ # % ' + / ? _ { } RFC 5322 (4.3.1) says the local part is a dot-atom, 3.2.3 says a dot-atom is a atext which includes alphanumeric plus the characters mentioned above. I'd be delighted to see an implementation that parses all corner cases, i.e. foo/bar=...@example.com or !foo%bar?baz*...@example.com, correctly. That might be a challenging Summer of Code assignment ;-) Happy Hacking ;-) Tobi -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAktYsaMACgkQPuBX/6ogjZ6xBQCgrkvs7pKQ6SKARF2ja20Wt0Bk pb4AoISpqLFf27yDVaiS3aAIJt8tMQqM =0XVy -END PGP SIGNATURE- ___ Evolution-hackers mailing list Evolution-hackers@gnome.org http://mail.gnome.org/mailman/listinfo/evolution-hackers
Re: [Evolution-hackers] mail address validation
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, On 21.01.2010 19:57, Tobias Mueller wrote: I'd be delighted to see an implementation that parses all corner cases, i.e. foo/bar=...@example.com or !foo%bar?baz*...@example.com, correctly. That might be a challenging Summer of Code assignment ;-) Just found this obviously correct RegEx in http://cpansearch.perl.org/src/MAURICE/Email-Valid-0.15/Valid.pm: $RFC822PAT = 'EOF'; [\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\ xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xf f\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\x ff]+(?![^(\040)@,;:.\\\[\]\000-\037\x80-\xff])|[^\\\x80-\xff\n\015 ]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015]*)*)[\040\t]*(?:\([^\\\x80-\ xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80 - -\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]* )*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\ \\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\ x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x8 0-\xff]+(?![^(\040)@,;:.\\\[\]\000-\037\x80-\xff])|[^\\\x80-\xff\n \015]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015]*)*)[\040\t]*(?:\([^\\\x 80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^ \x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040 \t]*)*)*...@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([ ^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\ \\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\ x80-\xff]+(?![^(\040)@,;:.\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80- \xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015() ]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\ x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\04 0\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\ n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\ 015()]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?! [^(\040)@,;:.\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\ ]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\ x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\01 5()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*|(?:[^(\040)@,;:. \\\[\]\000-\037\x80-\xff]+(?![^(\040)@,;:.\\\[\]\000-\037\x80-\xff] )|[^\\\x80-\xff\n\015]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015]*)*)[^ ()@,;:.\\\[\]\x80-\xff\000-\010\012-\037]*(?:(?:\([^\\\x80-\xff\n\0 15()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][ ^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)|[^\\\x80-\xff\ n\015]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015]*)*)[^()@,;:.\\\[\]\ x80-\xff\000-\010\012-\037]*)*[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(? :(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80- \xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:@[\040\t]* (?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015 ()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015() ]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?![^(\0 40)@,;:.\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\ [^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\ xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]* )*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80 - -\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x 80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t ]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?![^(\040)@,;:.\\ \[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff]) *\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x 80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80 - -\xff\n\015()]*)*\)[\040\t]*)*)*(?:,[\040\t]*(?:\([^\\\x80-\xff\n\015( )]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\ \x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*...@[\040\t ]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\0 15()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015 ()]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?![^( \040)@,;:.\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]| \\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80 - -\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015() ]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x 80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^ \x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040 \t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?![^(\040)@,;:. \\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff ])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\
Re: [Evolution-hackers] mail address validation
On Thu, 2010-01-21 at 20:17 +0100, Roberto -MadBob- Guido wrote: In the first version of the patch ( http://bugzilla-attachments.gnome.org/attachment.cgi?id=146701 ) I've provided a routine built on regular expressions (regcomp() and regexec()). Opinions about that? Please read my comment to the bug report, that I just added this morning. As Tobias mentions that RE is way too restrictive. My suggestion was this: ^[^;, \...@[-_.a-za-z0-9]+$ https://bugzilla.gnome.org/show_bug.cgi?id=213724 ___ Evolution-hackers mailing list Evolution-hackers@gnome.org http://mail.gnome.org/mailman/listinfo/evolution-hackers
Re: [Evolution-hackers] mail address validation
Tobias Mueller wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, On 21.01.2010 19:57, Tobias Mueller wrote: I'd be delighted to see an implementation that parses all corner cases, i.e. foo/bar=...@example.com or !foo%bar?baz*...@example.com, correctly. That might be a challenging Summer of Code assignment ;-) Just found this obviously correct RegEx in http://cpansearch.perl.org/src/MAURICE/Email-Valid-0.15/Valid.pm: [snip wall-of-regex] ugh, thanks for reminding me why I hate regex so much ;-) Jeff ___ Evolution-hackers mailing list Evolution-hackers@gnome.org http://mail.gnome.org/mailman/listinfo/evolution-hackers
Re: [Evolution-hackers] mail address validation
$RFC822PAT = 'EOF'; [\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\ (etc) I want a T-Shirt with that! I wonder what the RFC822 authors were smoking. Or is it possible to implement a correct RFC822 email address pattern matcher in code in a significantly simpler way than with a regex? Or is it simply so that no software actually properly implemented the spec until Jeff Friedl constructed that regex? --tml ___ Evolution-hackers mailing list Evolution-hackers@gnome.org http://mail.gnome.org/mailman/listinfo/evolution-hackers
Re: [Evolution-hackers] mail address validation
On Thu, 2010-01-21 at 15:16 -0500, Paul Smith wrote: Please read my comment to the bug report I've read, and you noticed something I didn't: it already exists a policy to validate a mail address, in the New Account wizard (more exactly: is_email() in mail/em-account-editor.c). It is ultra-permissive, the only comment above the only if() is /* make sure we have an '@' and that it's not the first or last gchar */ I think the same behaviour may be adopted elsewhere, because as you note mail address validation is far more complex than the rules described in RFCs and perhaps impossible to cover completely, but this little check would be far better than no validation at all. A `grep is_email * -r` find that this exactly routine has been pasted also in plugins/google-account-setup/google-source.c, e-util/e-html-utils.c also handles mail addresses checks, and it is now required in Contact List: what about move it once in some shared file? -- Roberto -MadBob- Guido http://claimid.com/madbob ___ Evolution-hackers mailing list Evolution-hackers@gnome.org http://mail.gnome.org/mailman/listinfo/evolution-hackers