9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] 'From' in outgoing mail considered harmful
@ 2002-10-11  8:51 Richard Miller
  2008-02-06  5:50 ` [9fans] Unescaped "From" in mail items Adrian Tritschler
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Miller @ 2002-10-11  8:51 UTC (permalink / raw)
  To: 9fans

When acme Mail saves a copy of sent mail in /mail/box/$user/outgoing, it doesn't
escape message lines beginning with 'From', as for example upas/send does.
This causes considerable confusion when trying to read the outgoing mailbox.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [9fans] Unescaped "From" in mail items
  2002-10-11  8:51 [9fans] 'From' in outgoing mail considered harmful Richard Miller
@ 2008-02-06  5:50 ` Adrian Tritschler
  2008-02-06  9:57   ` erik quanstrom
  2008-07-20  7:31   ` Russ Cox
  0 siblings, 2 replies; 5+ messages in thread
From: Adrian Tritschler @ 2008-02-06  5:50 UTC (permalink / raw)
  To: 9fans

I've just been archiving a bunch of old email that was sitting in IMAP
folders on a unix system somewhere into local folders on a plan9 system.
I used acme mail to access the remote IMAP folder then save the items I
wanted to local folders.

Some of these have an unescaped "^From" in the text, which seems to have
caused problems when I've saved them to the local mail folders.

The culprits seem to be multipart MIME, similar to:

  From News@InsideApple.Apple.com Tue Jun 19 12:14:30 EST 2007
  Return-Path: ...
  Content-Type: multipart/alternative;
	boundary="----=_Part_6716595_5283499.1182218824922"

  ------=_Part_6716595_5283499.1182218824922
  Content-Type: text/plain; charset=ISO-8859-1
  Content-Transfer-Encoding: quoted-printable
  Content-Disposition: inline

  Blah blah blah
  From $349
  ...
  ------=_Part_6716595_5283499.1182218824922
  Content-Type: text/html; charset=ISO-8859-1
  Content-Transfer-Encoding: quoted-printable
  Content-Disposition: inline
  ...misc HTML...
  ------=_Part_6716595_5283499.1182218824922--

Acme mail now reports multiple messages in the destination folders such
as:

111/	$199
110/	$349
109/	Apple <News@InsideApple.Apple.com>	Tue 19 Jun 2007
	iPod Gift Wrapping is now available.

upas/nedmail reports that the folder has 0 items in it, Acme mail that
it has 136 items.

Were the messages on the original server invalid before I started, is
acme mail handling them incorrectly when saving, or does upas/fs not
interpret them correctly after they've been saved locally?

     Adrian


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] Unescaped "From" in mail items
  2008-02-06  5:50 ` [9fans] Unescaped "From" in mail items Adrian Tritschler
@ 2008-02-06  9:57   ` erik quanstrom
  2008-07-20  7:31   ` Russ Cox
  1 sibling, 0 replies; 5+ messages in thread
From: erik quanstrom @ 2008-02-06  9:57 UTC (permalink / raw)
  To: 9fans

> Acme mail now reports multiple messages in the destination folders such
> as:
>
> 111/	$199
> 110/	$349
> 109/	Apple <News@InsideApple.Apple.com>	Tue 19 Jun 2007
> 	iPod Gift Wrapping is now available.
>
> upas/nedmail reports that the folder has 0 items in it, Acme mail that
> it has 136 items.
>
> Were the messages on the original server invalid before I started, is
> acme mail handling them incorrectly when saving, or does upas/fs not
> interpret them correctly after they've been saved locally?

this depends on your perspective.  upas says that's invalid.  this is what
i use to solve the problem by editing the mail.  (sed converts to
runes -- that's why it is avoided.)

- erik

; cat qfrom.c
/*
 * quote from lines without messing with character encoding.
 *	(might rather just undo the character encoding and use sed.)
 */

#include <u.h>
#include <libc.h>
#include <bio.h>

void
qfrom(int fd)
{
	Biobuf b, bo;
	char *s;
	int l;

	if(Binit(&b, fd, OREAD) == -1)
		sysfatal("Binit: %r");
	if(Binit(&bo, 1, OWRITE) == -1)
		sysfatal("Binit: %r");

	while(s = Brdstr(&b, '\n', 0)){
		l = Blinelen(&b);
		if(l >= 5)
		if(memcmp(s, "From ", 5) == 0)
			Bputc(&bo, ' ');
		Bwrite(&bo, s, l);
		free(s);
	}
	Bterm(&b);
	Bterm(&bo);
}

void
usage(void)
{
	fprint(2, "usage: qfrom [files...]\n");
	exits("");
}

void
main(int argc, char **argv)
{
	int fd;

	ARGBEGIN{
	default:
		usage();
	}ARGEND

	if(*argv == 0){
		qfrom(0);
		exits("");
	}
	for(; *argv; argv++){
		fd = open(*argv, OREAD);
		if(fd == -1)
			sysfatal("open: %r");
		qfrom(fd);
		close(fd);
	}
	exits("");
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [9fans] Unescaped "From" in mail items
  2008-02-06  5:50 ` [9fans] Unescaped "From" in mail items Adrian Tritschler
  2008-02-06  9:57   ` erik quanstrom
@ 2008-07-20  7:31   ` Russ Cox
  2008-07-22  1:21     ` erik quanstrom
  1 sibling, 1 reply; 5+ messages in thread
From: Russ Cox @ 2008-07-20  7:31 UTC (permalink / raw)


> Date: Tue Feb  5 23:56:46 EST 2008
>
> I've just been archiving a bunch of old email that was sitting in IMAP
> folders on a unix system somewhere into local folders on a plan9 system.
> I used acme mail to access the remote IMAP folder then save the items I
> wanted to local folders.
>
> Some of these have an unescaped "^From" in the text, which seems to have
> caused problems when I've saved them to the local mail folders.

This is acme mail's fault.  The easiest fix is to change
/acme/mail/src/mesg.c to do two writes: first use write
to write the header, and then use write2 to write the body
(write2 is in reply.c and knows how to escape From).
You'll probably also want to make write2 return whether
or not it succeeded.

Russ




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [9fans] Unescaped "From" in mail items
  2008-07-20  7:31   ` Russ Cox
@ 2008-07-22  1:21     ` erik quanstrom
  0 siblings, 0 replies; 5+ messages in thread
From: erik quanstrom @ 2008-07-22  1:21 UTC (permalink / raw)


> This is acme mail's fault.  The easiest fix is to change
> /acme/mail/src/mesg.c to do two writes: first use write
> to write the header, and then use write2 to write the body
> (write2 is in reply.c and knows how to escape From).
> You'll probably also want to make write2 return whether
> or not it succeeded.

it's a bit odd that the mail readers (Mail, ned, imap4d)
all use upas/fs to take care of reading mailboxes, but
when appending a message to a mailbox, all three
assume they know how mailboxes are structured.

- erik



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-07-22  1:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-11  8:51 [9fans] 'From' in outgoing mail considered harmful Richard Miller
2008-02-06  5:50 ` [9fans] Unescaped "From" in mail items Adrian Tritschler
2008-02-06  9:57   ` erik quanstrom
2008-07-20  7:31   ` Russ Cox
2008-07-22  1:21     ` erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).