mail-strip
that reads from std-in a mailbox in stupid UNIX
format and strips out the MIME attachments. The mailbox without the stripped
attachments is written to std-out.
The command-line option -f
mbox-name directs mail-strip
to read the mailbox
from the file named mbox-name rather than from std-in.
The mailbox file is in BSD "From " format.
Acceptance Tests
mail-strip
. Verify the file sent to
std-out is still in stupid UNIX format and contains no attachments.
Run /dev/null
through mail-strip
. Verify nothing bad happens.
Run a non-mailbox file through mail-strip
. Verify the output is identical to the
input.
If an attachment doesn't have a name or filename field, it should not be stripped from the mail message; unnamed attachments should be left as part of the mail message.
The saved attachment file should be written to the directory in which mail-strip
is
running. The command-line option -d
save-directory causes the
attachment files to be written to the directory save-directory
; mail-strip
should terminate with an error if save-directory
doesn't exist.
Acceptance Tests
mail-strip
and verify the proper saved files get created in the current directory.
Run the mailbox from the acceptance tests for story 1 through mail-strip
, saving the
files into the directory ~/attachments
. Verify the proper files have been
created in ~/attachments
.
Run the mailbox from the acceptance tests for story 1 through mail-strip
, saving the
files into the directory /this-directory-does-not-exist
. Verify nothing
bad happens.
mail-strip
command-line option -r
action determines how mail-strip
deals with
duplicate attachment files. The acceptable values for action, and the
associated actions, are
rename
- the new duplicate attachment file should saved in a file
renamed as follows: if the original name of the new duplicate attachment file
is fn, the name of the saved file is fn-
i where i is a
two digit, zero left-filled number (for example, 01
, 02
, and so on).
i should be one more than the largest value in any similarly named
saved-attachment file, or 01
if there's no such file.
overwrite
- the new duplicate attachment file replaces the old
duplicate attachment file. This is the default.
ignore
- the new duplicate attachment file is thrown away.
mail-strip
three times, one for each
possible value of the -r
option. Verify the correct things happened in
each case.
bool compare(const string & afn1, const string & afn2);
afn1
is the name (and path, if any) of one of the attachment files
and afn2
is the name (and path, if any) of the other attachment files.
compare()
should return true if the two files are duplicates and false
otherwise.
compare()
with a version that always returns false. Verify the
saved-file names when the mailbox from the acceptance tests for story 3 gets
run through mail-strip
with the -r rename
option.
Replace compare()
with a version that always returns true. Verify the
saved-file names when the mailbox from the acceptance tests for story 1 gets
run through mail-strip
with the -r rename
option.
This page last modified on 3 July 2001.