EmailField 3.X - Supporting Macrons to meet Maori Language Act

38 views
Skip to first unread message

Josh Kosmala

unread,
Jun 16, 2015, 12:06:30 AM6/16/15
to silverst...@googlegroups.com
Hey Stripers,

I've been informed, that in New Zealand, according to the Maori Language Act; email fields must accept tohu tohus (macrons).

There is a real need for all Government websites using CWP to comply to this act. I want to attack it and push it back to the core asap to avoid getting hit with OIA requests. I am less than pro at regex/pcre. Am I needing to play with the expression on line 36 of EmailField?

Any suggestions, advice, RFC issues or guidance in this matter will be greatly accepted.

Best,
Josh

Ingo Schommer

unread,
Jun 16, 2015, 12:27:41 AM6/16/15
to silverst...@googlegroups.com
Thanks for bringing this up, Josh. 

You're correct to say that email addresses can contain multibyte characters like macrons (https://en.wikipedia.org/wiki/Email_address#Local_part, https://tools.ietf.org/html/rfc6531). The EmailField regex in https://github.com/silverstripe/silverstripe-framework/blob/3.1/forms/EmailField.php#L42 doesn't account for that. You could research an RFC6531 compliant PHP regex, and test it on http://regexr.com/ with a few variations. Write a few unit tests for EmailField, and you're welcome to submit a pull request. 

BTW: This discussion is generally better suited as a Github issue than on the core mailinglist.

Thanks
Ingo

--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.



--
Ingo Schommer | Solutions Architect
SilverStripe (http://silverstripe.com)
Mobile: 0221601782
Skype: chillu23

Josh Kosmala

unread,
Jun 16, 2015, 12:29:23 AM6/16/15
to silverst...@googlegroups.com
Thanks Ingo, will action as per your advice. Cheers!

Josh Kosmala

NovaWeb
022 048 5704



--
You received this message because you are subscribed to a topic in the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/silverstripe-dev/ftgUlm2AjBU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to silverstripe-d...@googlegroups.com.

Patrick Nelson

unread,
Jun 16, 2015, 1:40:29 AM6/16/15
to silverst...@googlegroups.com
One thing to be aware of in preg_*/pcre: The "u" flag. Turns out, this is your best friend. Otherwise, nothing will ever match. Can be pretty frustrating trying to figure out why nothing works (just because you've got one unicode char in your matching string) only to find out you need to manually specify that you're using unicode/UTF-8. Stack overflow to the rescue: http://stackoverflow.com/questions/1725227/preg-match-and-utf-8-in-php

Daniel Hensby

unread,
Jun 16, 2015, 4:56:05 AM6/16/15
to silverst...@googlegroups.com

Does php's filter_var not handle multibyte email adresses?

Daniel Hensby

unread,
Jun 16, 2015, 6:18:51 AM6/16/15
to silverst...@googlegroups.com
A quick test shows it does not

Patrick Nelson

unread,
Jun 16, 2015, 9:24:34 AM6/16/15
to silverst...@googlegroups.com
I did not know that actually. Pretty lame as that's supposed to be a good standard alternate to having your own monster regex for validating email. But indeed, based on the discussion I'm seeing elsewhere, if you want to validate emails with Unicode chars in the local part, you'll need to avoid filter_var(), which ironically will still be very permissive anyway (aside from incompatibility with Unicode). 

Sent from my iPad

Josh Kosmala

unread,
Jun 17, 2015, 12:55:21 AM6/17/15
to silverst...@googlegroups.com
Thanks all, this discussion now continued at https://github.com/silverstripe/silverstripe-framework/issues/3057
Reply all
Reply to author
Forward
0 new messages