[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch: e-mail extraction



I slightly modified &extract_email_address from mhutil.pl (v.2.5.2) with a
more rigorous regular expression check, to handle slightly misformed From
headers:

This corrected a problem I had with a malformed From header of the form:

  From: Joe Schmoe" <joe@schmoe.com

Ugh.  Gotta love those MUAs. :-)

The diff is:

66c66,69
<     if ($str =~ /<(\S+)>/) {
---
>     if ($str =~ /([\w\-\.]+\@[\w\-\.]+)/) {
>         $ret = $1;
>     }
>     elsif ($str =~ /<(\S+)>/) {

Basically, as a first check, it tries to extract a string of the form:

  [alphanumeric, '_', '-', '.']+\@[alphanumeric, '_', '-', '.']+

If it doesn't find anything like that, it goes through the other checks.

-Eugene

-- 
+=== Eugene Eric Kim ===== eekim@eekim.com ===== http://www.eekim.com/ ===+
|       "Writer's block is a fancy term made up by whiners so they        |
+=====  can have an excuse to drink alcohol."  --Steve Martin  ===========+


[Index of Archives]     [Bugtraq]     [Yosemite News]     [Mhonarc Home]