Hi David,
messageid=`grep -i ^Message-Id "$1" | \
sed -e 's/^[Mm][Ee][Ss][Ss][Aa][Gg][Ee]-[Ii][Dd]: *<*//' -e 's/>$//' | \
tr '[/\\]' '[..]'`
My inner sed prefers replacing those three with
mi=`sed -n '
/^$/q; /^[Mm][Ee][Ss][Ss][Aa][Gg][Ee]-[Ii][Dd]:/!d
s/>.*//; s/.*<//; y#/\\#..#; p
' "$1"`
:-) It also avoids reading the whole of the email. BTW, your brackets
for tr are actually asking it to transliterate an open bracket to an
open bracket and so on.
# Message-IDs should be unique, so there should be no need to
# backup a file with the same name, especially if it is
# malicious. If the backup file already exists, use 2).
Even if they are unique, and I've had incoming ones that aren't, they
could differ in a way that's removed by y#/#.#. I wonder if the
fallback should be to use $mi as the base for whatever the POSIX way of
mktemp(1) is and let it avoid the clash. That may, message-ID is still
the base.
Cheers, Ralph.
_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers