From the translator: having read the article , I began to reply in the comments, but decided that the text I was going to refer to was worthy of a separate publication. MeetIf you know how to validate an email address, raise your hand. Those of you who raised your hand - lower it immediately, until someone saw you: it's stupid enough to sit alone at the keyboard with your hand raised; I spoke in a figurative sense.
Consequently - and due to a long series of problems caused by intermediate hosts trying to optimize the transmission by changing their [addresses - transl. ], the local part MUST be interpreted (and it should be assigned a semantic meaning) exclusively by the server specified in the domain part of the address .Section 3.4.1 of RFC 2822 describes additional details of the email address specification (highlighted by me - auth. ).
An address specification is a specific identifier on the Internet, containing a locally interpreted string, followed by the “at” sign (“@”, ASCII code 64), which, in turn, is followed by the Internet domain. A locally interpreted string is either a string-delimited string or a dotted atom .A dot atom is a collection of atoms separated by dots. In turn, the atom is defined in section 3.2.4 as a set of alphanumeric characters and may include any of the following symbols (you know, the ones that are usually replaced with the mat) ...
! \$ & * - = ^ ` | ~ # % ' + / ? _ { }
"Abc\@def"@example.com
"Fred Bloggs"@example.com
"Joe\\Blow"@example.com
"Abc@def"@example.com
customer/department=shipping@example.com
\$A12345@example.com
!def!xyz%abc@example.com
_somename@example.com
^(?!\.)("([^"\r\\]|\\["\r\\])*"|([-a-z0-9!#$%&'*+/=?^_`{|}~] |(?@[a-z0-9][\w\.-]*[a-z0-9]\.[az][az\.]*[az]$
[RowTest] [Row(@"NotAnEmail", false)] [Row(@"@NotAnEmail", false)] [Row(@"""test\\blah""@example.com", true)] [Row(@"""test\blah""@example.com", false)] [Row("\"test\\\rblah\"@example.com", true)] [Row("\"test\rblah\"@example.com", false)] [Row(@"""test\""blah""@example.com", true)] [Row(@"""test""blah""@example.com", false)] [Row(@"customer/department@example.com", true)] [Row(@"$A12345@example.com", true)] [Row(@"!def!xyz%abc@example.com", true)] [Row(@"_Yosemite.Sam@example.com", true)] [Row(@"~@example.com", true)] [Row(@".wooly@example.com", false)] [Row(@"wo..oly@example.com", false)] [Row(@"pootietang.@example.com", false)] [Row(@".@example.com", false)] [Row(@"""Austin@Powers""@example.com", true)] [Row(@"Ima.Fool@example.com", true)] [Row(@"""Ima.Fool""@example.com", true)] [Row(@"""Ima Fool""@example.com", true)] [Row(@"Ima Fool@example.com", false)] public void EmailTests(string email, bool expected) { string pattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|" + @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)" + @"@[a-z0-9][\w\.-]*[a-z0-9]\.[az][az\.]*[az]$"; Regex regex = new Regex(pattern, RegexOptions.IgnoreCase); Assert.AreEqual(expected, regex.IsMatch(email) , "Problem with '" + email + "'. Expected " + expected + " but was not that."); }
phil.h\@\@ck@haacked.com
and start complaining to tech support on sites that require you to enter an email address, but do not allow me to create an account with this address. I love to misbehave!Source: https://habr.com/ru/post/274985/
All Articles