Re: BODYSTRUCTURE question

2007-02-27 Thread Mike Cathey
On Tue, 2007-02-27 at 16:56 +1100, Rob Mueller wrote:
  As of RFC 2045, Content-Type syntax should be:
  content := Content-Type : type / subtype *(; parameter)
 
  Shouldn't cyrus still interpret this as text/html, despite the illegal  
  boundary... line following Content-Type ?
 
 I've noticed this too, and while it clealy is broken with respect to the 
 RFC, it's annoying to deal with. In the meantime, I fix up these headers in 
 our custom perl lmtp proxy system with a regexp like this on Content-Type 
 headers...

Nice!  Is this code available for public consumption?  I'd love to use
something like this to strip out \0s in messages too.  Most of the other
solutions for cyrus/postfix that I've seen required an additional
exec() in the delivery pipeline, which I would like to avoid.

Cheers,

Mike
-- 
Mike Cathey - http://www.mikecathey.com/
Network Administrator
RTC Internet - http://www.catt.com/


signature.asc
Description: This is a digitally signed message part

Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

Re: BODYSTRUCTURE question

2007-02-27 Thread Robert Mueller

 Nice!  Is this code available for public consumption?  I'd love to use
 something like this to strip out \0s in messages too.  Most of the other
 solutions for cyrus/postfix that I've seen required an additional
 exec() in the delivery pipeline, which I would like to avoid.

It's all done in perl, and the actual complete proxy is in house
unfortunately, however some of the surrounding modules are available.

http://cpan.robm.fastmail.fm/other/

Unfortunately the documentation is a bit old or lacking, but the basic
idea is something like:

package LmtpProxy;
use base qw(Net::Server::Fork Net::XmtpServer);

LmtpProxy-run(
  port = /var/imap/socket/lmtpproxy,
  xmtp_personality = 'lmtp',
  handle_mime = 1,
);

sub new_connection {
  $_[0]-send_client_resp(220, Welcome);
}
sub helo {
  $_[0]-send_client_resp(250, Helo ok);
}
sub mail_from {
  $_[0]-{mail_from} = $_[1];
  $_[0]-send_client_resp(250, RCPT TO ok);
}

... etc rcpt_to, begin_data, end_data, rset ...
... you can also hook into begin_body, end_body, begin_headers,
end_headers, header, etc

sub header {
  if (lc $_[1] eq content-type) {
$_[2] =~ s{^([\w\-]+/[\w\-]+)(\s+[\w\-]+\s*=)}{$1;$2};
  }
}

sub end_data {
  # open Net::XmtpClient connection to backend server to replay lmtp
  commands
}

Rob

--
[EMAIL PROTECTED]
Sign up at http://fastmail.fm for fast, ad free, IMAP accessible email


Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html


Re: BODYSTRUCTURE question

2007-02-26 Thread Rob Mueller

As of RFC 2045, Content-Type syntax should be:
content := Content-Type : type / subtype *(; parameter)

Shouldn't cyrus still interpret this as text/html, despite the illegal  
boundary... line following Content-Type ?


I've noticed this too, and while it clealy is broken with respect to the 
RFC, it's annoying to deal with. In the meantime, I fix up these headers in 
our custom perl lmtp proxy system with a regexp like this on Content-Type 
headers...


 # Fix up broken Content-Type headers missing ; between
 # type and first parameter
 s{^([\w\-]+/[\w\-]+)(\s+[\w\-]+\s*=)}{$1;$2};

Rob


Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html