Skip to content

Instantly share code, notes, and snippets.

@blech75
Created January 25, 2012 15:05
Show Gist options
  • Save blech75/1676673 to your computer and use it in GitHub Desktop.
Save blech75/1676673 to your computer and use it in GitHub Desktop.
why sending regexps via email is a bad idea
// client attempts to send a regexp in the body of an email message. it
// didn't work. the "file:///" was the telltale sign something was wrong.
//
// the irony here, of course, is that it's a regexp for validating email
// addresses. (and what a regexp it is!)
// pasted into email body in outlook (FAIL!)
REGEX_EMAIL = new RegExp("^([^()<>@,;:\\\\\".\\s\\x00-\\x1F\\x7F\\[\\]]+|\"([^\\\\\"\\x0D]|\\\\.)*\<file:///\\x0D]|\.)*\>")(\\.([^()<>@,;:\\\\\".\\s\\x00-\\x1F\\x7F\\[\\]]+|\"([^\\\\\"\\x0D]|\\\\.)*\"))*@([abcdefghijklmnopqrstuvwxyz0123456789]([-abcdefghijklmnopqrstuvwxyz0123456789]*[abcdefghijklmnopqrstuvwxyz0123456789])?)((\\.([abcdefghijklmnopqrstuvwxyz0123456789]([-abcdefghijklmnopqrstuvwxyz0123456789]*[abcdefghijklmnopqrstuvwxyz0123456789])?))*)(\\.([abcdefghijklmnopqrstuvwxyz0123456789]{2}|com|edu|gov|int|mil|net|org|biz|info|name|pro|aero|coop|museum|cat|jobs|mobi|tel|travel|xxx))$<file:///\\.([%5e()%3c%3e@,;:\%22.\s\x00-\x1F\x7F\%5b\%5d%5d+|\%22(%5b%5e\%22\x0D%5d|\.)*\%22))*@(%5babcdefghijklmnopqrstuvwxyz0123456789%5d(%5b-abcdefghijklmnopqrstuvwxyz0123456789%5d*%5babcdefghijklmnopqrstuvwxyz0123456789%5d)%3f)((\.(%5babcdefghijklmnopqrstuvwxyz0123456789%5d(%5b-abcdefghijklmnopqrstuvwxyz0123456789%5d*%5babcdefghijklmnopqrstuvwxyz0123456789%5d)%3f))*)(\.(%5babcdefghijklmnopqrstuvwxyz0123456789%5d%7b2%7d|com|edu|gov|int|mil|net|org|biz|info|name|pro|aero|coop|museum|cat|jobs|mobi|tel|travel|xxx))$>", "i"); // Note: for some reason [a-z], under some engines, behaves as \w (i.e. [_a-z])
// included as an attachment (yay!)
REGEX_EMAIL = new RegExp("^([^()<>@,;:\\\\\".\\s\\x00-\\x1F\\x7F\\[\\]]+|\"([^\\\\\"\\x0D]|\\\\.)*\")(\\.([^()<>@,;:\\\\\".\\s\\x00-\\x1F\\x7F\\[\\]]+|\"([^\\\\\"\\x0D]|\\\\.)*\"))*@([abcdefghijklmnopqrstuvwxyz0123456789]([-abcdefghijklmnopqrstuvwxyz0123456789]*[abcdefghijklmnopqrstuvwxyz0123456789])?)((\\.([abcdefghijklmnopqrstuvwxyz0123456789]([-abcdefghijklmnopqrstuvwxyz0123456789]*[abcdefghijklmnopqrstuvwxyz0123456789])?))*)(\\.([abcdefghijklmnopqrstuvwxyz0123456789]{2}|com|edu|gov|int|mil|net|org|biz|info|name|pro|aero|coop|museum|cat|jobs|mobi|tel|travel|xxx))$", "i"); // Note: for some reason [a-z], under some engines, behaves as \w (i.e. [_a-z])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment