non-latin email address validation

后端 未结 2 1023
太阳男子
太阳男子 2021-01-02 04:23

Now that ICann is allowing non-latin-character domain names, should I be concerned about e-mail validation? Currently, my sites are using php functions to ensure some alpha

2条回答
  •  渐次进展
    2021-01-02 04:41

    I think the ultimately best way would be using a proper IDN function to convert the incoming string into an ACE string (xn--xyz-blah.com). If that process works, the domain name is valid. If it doesn't, it isn't.

    There is a PHP function named idn_to_ascii() that does this, but it needs additional libraries. You'd have to see whether it is available on your system.

    There also seems to be an external Linux command named idn that does IDN conversions. I don't know anything further about it, though.

    If you want to use PHP built-in methods only, delfuego provides a regular expression in this question that looks very good.

提交回复
热议问题