为什么sfValidatorEmail会接受口音?

时间:2021-03-25 07:27:20

There was a bug in my application, apparently accents in an email address where not considered an error and the sfMailer was crashing an error because of this.

在我的应用程序中有一个错误,很明显是电子邮件地址的重音,在那里不认为是错误,sfMailer因为这个原因崩溃了一个错误。

Digging through my code I realized I wasn't to blame.

我翻遍了我的代码,意识到这不是我的错。

sfValidatorEmail uses this regular expression:

sfValidatorEmail使用这个正则表达式:

const REGEX_EMAIL = '/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i';

Accents in the first part of the email are accepted.

邮件第一部分的口音可以接受。

Should sfValidatorEmail not accept accents or should sfMailer accept it?

sfValidatorEmail是否应该不接受重音,或者sfMailer接受它?

2 个解决方案

#1


3  

sfMailer should accept it. It is legitimate to have accents in the first part of the email address.

sfMailer应该接受它。在电子邮件地址的第一部分有口音是合法的。

#2


0  

According to wikipedia accents are valid. Off course, in practice, in webprogramming, I try to avoid anything (spaces, accents,...) that can upset the 'internet middle layer' (i.e. routers, servers, etc).

根据*的口音是有效的。当然,在网络编程的实践中,我尽量避免(空格,重音,…),这会打乱“互联网中间层”(即路由器、服务器等)。

#1


3  

sfMailer should accept it. It is legitimate to have accents in the first part of the email address.

sfMailer应该接受它。在电子邮件地址的第一部分有口音是合法的。

#2


0  

According to wikipedia accents are valid. Off course, in practice, in webprogramming, I try to avoid anything (spaces, accents,...) that can upset the 'internet middle layer' (i.e. routers, servers, etc).

根据*的口音是有效的。当然,在网络编程的实践中,我尽量避免(空格,重音,…),这会打乱“互联网中间层”(即路由器、服务器等)。