Home | History | Annotate | Download | only in mail
History log of /src/usr.bin/mail/mime_attach.c
RevisionDateAuthorComments
 1.21  27-Jun-2025  andvar Grammar and spelling fixes, mainly in comments. A few in documentation,
logging, test description, and SCSI ASC/ASCQ assignment descriptions.
 1.20  01-Feb-2019  mrg branches: 1.20.12;
compare pointers with NULL not '\0'.
 1.19  09-Nov-2017  christos branches: 1.19.4;
Only open regular files.
 1.18  17-Jun-2015  christos one more stray \n
 1.17  18-Oct-2013  christos fix unused variable warnings
 1.16  04-Jan-2013  christos PR/47396: Steffen: mail(1) may falsely use quoted-printable for files with
embedded NULs
 1.15  04-Jan-2013  christos PR/47395: Steffen: mail(1) unnecessarily uses base64 if a CR without a LF is seen
 1.14  29-Apr-2012  christos branches: 1.14.2;
set close on exec for all opened files.
 1.13  11-Apr-2009  christos branches: 1.13.6;
- magic fix for short files
- knf
from Anon Ymous
 1.12  10-Apr-2009  christos From Anon Ymous:

- Remove all longjmp(3) calls from signal handlers. Instead, we post
to an internal signal queue and check that periodically. All signal
related code is now in sig.c, except for the SIGCHLD handler which
remains in popen.c as it is intimately tied to routines there.

- Handle SIGPIPE in type1() regardless of mime support, or else the
handler in execute() will prevent our error code from being returned
resulting in 'sawcom' not being set on the first command as it should.
This only affected the initial behavior of the "next" command without
mime support.

- Add the 'T' flag to many commands in cmdtab.c that should not look
like the first command. E.g., start mail on a mailbox with multiple
messages, run "set foo", then "next", and watch the second message get
displayed rather than the first as is the case without the first "set"
command.

- Add file descriptor and file handle leak detection. Enabled by
DEBUG_FILE_LEAK. This will likely disappear in the future.

- Fix a long standing (since import in 1993) longjmp() bug in
edstop(): the jmpbuf was invalid when quit() is called at the end of
main.

- Fix a long standing bug (since import in 1993) in snarf() where it
didn't strip whitespace correctly if the line consisted only of
whitespace.

- Lint cleanup.

- New Feature: "Header" command. This allows miscellaneous header
fields to be added to the header, e.g., "X-Organization:" or
"Reply-To:" fields.

- New Feature: "page-also" variable. This allows the specification of
additional commands to page. It is more flexible than "crt".

- Document the "pager-off" variable: if set, it disables paging
entirely.
 1.11  11-Mar-2009  christos fix warnings.
 1.10  28-Apr-2008  martin branches: 1.10.8;
Remove clause 3 and 4 from TNF licenses
 1.9  24-Apr-2008  christos Fix a header decode mistake that caused mime header lines decoded by
hfield() to be decoded as if they were "unstructured" regardless of
their type. This resulted from calling mime_decode_hfield() with the
body of the header line, i.e., the portion after the colon header
field name terminator, rather than the full header line.
From Anon Ymous
 1.8  14-Dec-2007  christos branches: 1.8.4;
From Anon Ymous:
- Fix a file handle leak.
- Use Fopen(), Fdopen(), and Fclose() consistently so the signal
handler close files.
 1.7  30-Oct-2007  christos From Anon Ymous:

- Add a "forward" command as requested by garbled@.
From the manpage:

forward
Takes a list of messages and prompts for an address (or
addresses) to forward each message to. If no message list is
specified, the current message is used. The mail editor is run
for each message allowing the user to enter a message that will
precede the forward message. The message is sent as a multi-
part/mixed MIME encoded message.

- Add the ability to match messages that do (or do not) contain a
header field. E.g., the command "f ! /Subject:" will display the
list of messages that are missing a "Subject" field.

- Teach savemail() to prefix fake headlines so the mbox doesn't get
broken.

- Fixed a couple of "bugs" in the attachment editing routine.
 1.6  29-Oct-2007  christos From Anon Ymous:
knf changes:
- s/sizeof x/sizeof(x)/.
- remove unnecessary malloc typecasts.
- whitespace nits.
 1.5  23-Oct-2007  christos From Anon Ymous:
- Introduce date_to_tm() and hl_date_to_tm() to parse the date and
headline date a bit more efficiently.
- If 'tm_isdst' is determined, let strftime(3) handle the '%Z' and
'%z' formats. Otherwise, output "-0000" and "???", respectively, to
help preserve with alignment; strftime(3) will output an empty
string in these case.
- Change fail() to use the '-d' flag (which sets the 'debug' variable)
rather than the "debug" _environment_ variable. This is more
consistent with other warnings.
- Don't use gcc C extensions, e.g., "case LOW ... HIGH:".
- Define is_WSP() in def.h to be an inline function that for checks
whitespace (WSP = ' ' or '\t'), as defined in RFC 2822. Use it
consistently in place of isblank().
- For consistency, rename skip_blank() to skip_WSP().
- Add inline skip_space() to complement skip_blank() (now skip_WSP).
- Check all ctype(3) calls for argument range issues.
- Whitespace and comment cleanup/changes.
 1.4  03-Jan-2007  christos branches: 1.4.4;
1) Fix a really stupid table termination error in mime_decode.c.

2) When doing attachments set the "name=" parameter of the
Content-Type field, in addition to the (already) set "filename="
parameter of the Content-Disposition field. Some utilities (e.g.,
metamail) use this parameter for the filename even though (I believe)
the "filename=" parameter of the Content-Disposition field is
preferred by the standard (I can't find this explicitly except for
"application/octet-stream" types - see RFC1521 sec 7.4.1 and RFC2046
sec 4.5.1). My impression is that the "name=" parameter of the
Content-Types field is really intended for use when retrieving a file
not in the message, e.g., "message/external-body" Content-Types, and
not for the filename.
(Thanks to wiz@ for noticing this in his spam logs.)

3) Be more careful when determining the Content-Type of 1-byte
attachments. libmagic(3) isn't helpful on such small files.
 1.3  28-Nov-2006  christos branches: 1.3.2;
From Anon Ymous:

1) Statification of modules.

2) Implement the 'detach' and 'Detach' commands for extracting mime
parts from messages.

3) Teach mail to output "In-Reply-To" and "References" header fields
when replying so others can thread us.

4) Implement threading, sorting, and tagging, supported by the
following commands: 'flatten', 'reverse', 'sort', 'thread',
'unthread', 'down', 'tset', 'up', 'expose', 'hide', 'tag',
'untag', 'invtags', 'tagbelow', 'hidetags', 'showtags'.
See the manpage for details (when available - soon).

5) Implement a 'deldups' command to delete duplicate messages based on
their "Message-Id" field, e.g., in replies to a mailing list that
are also CCed to a subscriber. (This can also be accomplished with
the threading and tagging commands.)

6) Implement 'ifdef' and 'ifndef' commands, and make the conditionals
nestable (i.e., implement a conditional stack). The if/else/endif
commands existed before, but they were primitive and undocumented.
The 'if' command currently recognizes the "receiving", "sending",
and "headersonly" mode keywords.

7) Teach the message selecting routine to understand regular
expressions if "regex-search" is defined. Otherwise only case
insensitive substring matches are done (as in the past).

8) Teach the message selection routine to understand boolean
expressions. Improved "colon-modifier" support. See the manpage
for details (when available - soon).

9) Extend paging to all commands (where relevant).

10) Add shell like piping and redirection of (standard) output (if
"enable-piping" is defined). Extend completion to these contexts.

11) The manpage should follow soon!!!!
 1.2  31-Oct-2006  christos More fixes from Anon Ymous:


1) Removed the -B flag (it was stupid on my part) and added a short
description indicating how to accomplish the same thing under the
"Sending Mail" section of man mail(1).

2) Added a -H flag to dump the headers and exit. It takes optional
flags to restrict to old, new, read, unread, and deleted messages
(the later being kind of useless - it shares code with something
that already had it).

3) Restored the 'Save' command which somehow got mistakenly removed in
the last commit and add documentation for it! (My apologies to
its author.)

4) Added a 'mkread' command to mark messages as read (the inverse of
'unread'). Should we also have a 'mknew' command?

5) Added a 'smopts' command to keep a database of addresses and
sendmail options to be used when sending messages to those
addresses. See man mail(1) for a fuller description.

6) Added 'indentpreamble' and 'indentpostscript' variables whose
values are inserted before and after a quoted message (~m or ~M
escapes).
=20
7) Added string formatting abilities for the 'prompt', 'insertpreamble',
'insertpostscript', and header display strings. These strings
support all the strftime() format parameters as well as many more
specific to mail (see man mail(1)).

8) Fix the -a flag so that it only takes a single filename, unless
"mime-attach-list" is defined. This is more conventional and avoids
unexpected whitespace issues.
 1.1  21-Oct-2006  christos From our anonymous user:
- mime and character set handling
- command line editor and completion
- many code improvements
 1.3.2.1  19-Feb-2007  tron Pull up following revision(s) (requested by christos in ticket #454):
usr.bin/mail/mime_attach.c: revision 1.4
usr.bin/mail/mime_decode.c: revision 1.8
1) Fix a really stupid table termination error in mime_decode.c.
2) When doing attachments set the "name=" parameter of the
Content-Type field, in addition to the (already) set "filename="
parameter of the Content-Disposition field. Some utilities (e.g.,
metamail) use this parameter for the filename even though (I believe)
the "filename=" parameter of the Content-Disposition field is
preferred by the standard (I can't find this explicitly except for
"application/octet-stream" types - see RFC1521 sec 7.4.1 and RFC2046
sec 4.5.1). My impression is that the "name=" parameter of the
Content-Types field is really intended for use when retrieving a file
not in the message, e.g., "message/external-body" Content-Types, and
not for the filename.
(Thanks to wiz@ for noticing this in his spam logs.)
3) Be more careful when determining the Content-Type of 1-byte
attachments. libmagic(3) isn't helpful on such small files.
 1.4.4.2  09-Jan-2008  matt sync with HEAD
 1.4.4.1  06-Nov-2007  matt sync with HEAD
 1.8.4.1  18-May-2008  yamt sync with head.
 1.10.8.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.13.6.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.6.2  23-Jan-2013  yamt sync with head
 1.13.6.1  23-May-2012  yamt sync with head.
 1.14.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.2.1  25-Feb-2013  tls resync with head
 1.19.4.1  10-Jun-2019  christos Sync with HEAD
 1.20.12.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed