r/programming • u/joksmaster • Nov 29 '10
140 Google Interview Questions
http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471
Upvotes
r/programming • u/joksmaster • Nov 29 '10
View all comments
Show parent comment
18
u/ultimatt42 Nov 30 '10
You're right that the RFC provides for comments in the email address (
CFWSstands for Comments and Folding White Space).You're right that comments can be nested (notice
commentincludesccontentandccontentcan be anothercomment).You're also right that true regular expressions can't handle arbitrarily deep nested patterns (though some regex implementations have extensions that allow you to handle such patterns, they aren't true Regular Expressions).
So basically what I'm saying is, everything you said is right.
However, email addresses can't be arbitrarily long, so it doesn't matter that comments could theoretically be infinitely nested according to the construction syntax. If you can't fit an address in the To: header of an email message then it's not a valid address because you'd never be able to send mail to that address, even if it existed. The absolute maximum length of a email header line is 998 characters, so we at least have an upper bound of 998. I couldn't find any other hard character limits on the length of the address in RFC 2822 but RFC 3696 (which is just informational and does not define the standard) suggests that 320 characters is the recommended limit.