=========================================
Bug #1 : Address extraction from a header
=========================================

We have a function, written in sh, that returns the first
address in a RFC822 header. I want to replace it because

  - It is klunky
  - It can screw up when there are quotes, possibly other times.
  - I suspect some regexp based function would do a better job

The function is allowed to be very expensive, although I'd prefer not
to fire up perl. It's only used when we see a new list for the first
time; I think the record so far has been 30 executions in one day.

Bonus: if the function extracted all addresses in the header, (instead
of just the first one) that would help me improve another part of the
program. (specifically, the new list heuristics)

Severity: This bug can put a few cluttered lines in the trouble log,
and a few times a week causes a valid message to be misdiagnosed as
corrupt. (Requiring the dreaded manual sorting.)

I think this would probably be easy if I knew awk. Here's the
function:

########################################################
# Function for getting first email address in a header #
########################################################

# Usage example:
# snarf-address "To: Multiple recipients of list <[EMAIL PROTECTED]>"

snarf-address () {
    echo $@ | cut -f2- -d" " | cut -f2 -d"<" | cut -f1 -d">" |\
    cut -f1 -d, | cut -f1 -d" " | head -1
}

Reply via email to