前几天我读了一篇文章,其中简要介绍了大多数现代网站中的一些常见验证缺陷,我决定对其进行一些研究。
事实证明,大多数网站和电子邮件提供商(hotmail、yahoo)的验证过于严格。
-
RFC 2821 第 2.3.10 节
因此,由于中间主机尝试通过修改它们来优化传输时出现的问题由来已久,因此本地部分必须仅由地址的域部分中指定的主机来解释和分配语义。
在 RFC 2822 的第 3.4.1 节中它更详细地说明了用户解释的字符串应该是什么!
addr-spec 是一个特定的 Internet 标识符,包含本地解释的字符串,后跟 at 符号字符(“@”,ASCII 值 64),最后是 Internet 域。本地解释的字符串是引用字符串或点原子。
在 RFC 2822 的第 3.2.4 节最后,告诉我们点原子可以包含以下任何字符
$& * - = ^ ` | 〜#%'+/? _ { }
在 RFC 3696 中进一步显示有效电子邮件列表。
现在,我向大家提出的问题是,我应该如何严格地验证电子邮件。根据RCF?或根据人群。大多数人也在验证什么?
I read an article the other day that briefly touched base on some common validation flaws in most modern websites, and I decided to do some research on it.
Turns out, MOST websites, and email providers (hotmail, yahoo) are being TOO STRICT with their validation.
-
In section 2.3.10 of RFC 2821
Consequently, and due to a long history of problems when intermediate hosts have attempted to optimize transport by modifying them, the local-part MUST be interpreted and assigned semantics only by the host specified in the domain part of the address.
In section 3.4.1 of RFC 2822 It goes into more detail as to what the user-interpreted string should be!
An addr-spec is a specific Internet identifier that contains a locally interpreted string followed by the at-sign character ("@", ASCII value 64) followed by an Internet domain. The locally interpreted string is either a quoted-string or a dot-atom.
In section 3.2.4 of RFC 2822 And finnally, tells us that a dot-atom may include any of the following characters
$ & * - = ^ ` | ~ # % ' + / ? _ { }
In RFC 3696 It goes further to display a list of valid emails.
Now, My question to all you guys out there, how strict should I validate emails. According to the RCF? or according to the crowd. And what are the majority of people out there validating too?
发布评论
评论(1)
我通常使用正则表达式来验证电子邮件。 Regular-Expressions.info 有一个好页面,包括一个应该符合的正则表达式RFC 2822。
另一个问题是哪个 ISP 允许使用以下电子邮件地址: !def!xyz%[email ;受保护], customer/[电子邮件受保护], "弗雷德·博客“@example.com ?我怀疑极少数(如果有的话)。我认为您不必担心这些奇怪的情况,因为它们很少被使用(据我所知 - 我从未见过使用这些表单的任何地址)。
I usually use a regex to validate emails. regular-expressions.info has a good page, including a regex that is supposed to conform to RFC 2822.
Another question is which ISP allows email addresses like: !def!xyz%[email protected], customer/[email protected], "Fred Bloggs"@example.com ? I suspect very few, if any. I think you don't have to worry about these odd cases as they are very rarely used (to the best of my knowledge - I have never seen any addresses of these forms in use).