🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #68485

Re: MIME peculiarities (C-T and C-T-E); help please!

#68485
From: Russ Allbery
Date: Tue, 09 Mar 2004 19:13
65 lines
4397 bytes
In news.software.nntp, Gregg Woodcock <woodcock@SonLightSoftware.com> writes:

> #1: Is it valid for a multipart MIME message to have the
> "Content-Transfer-Encoding" header in the main (envelope) header?  RFC
> 1521 clearly implies (but does not directly state) it is not valid but
> yet I see it happening anyway.  If it is invalid, should it just be
> ignored?

RFC 1521 is obsolete; the current standard is RFC 2045.  It says:

6.4.  Interpretation and Use

   If a Content-Transfer-Encoding header field appears as part of a
   message header, it applies to the entire body of that message.  If a
   Content-Transfer-Encoding header field appears as part of an entity's
   headers, it applies only to the body of that entity.  If an entity is
   of type "multipart" the Content-Transfer-Encoding is not permitted to
   have any value other than "7bit", "8bit" or "binary".  Even more
   severe restrictions apply to some subtypes of the "message" type.

which seems to imply that CTE is valid at the top level and applies to the
whole message.  Note, however, that this text bans any CTE at the top
level that requires you to *do* anything (no quoted-printable or base64),
which means that in practice I believe all it does is set the default CTE
for all the parts of the multipart.

> If it is valid, to what does it apply?  If it is valid my guess would be
> that it applies to any sub-part to which it can apply but which does not
> already have it's own Content-Transfer-Encoding header.  What if both
> parts have this header (I assume the sub-part's header "wins")?

The CTE in the sub-part would override the CTE at the top level.  Note,
however, that if the top level CTE claims that the message is 7bit,
obviously no sub-part could have a CTE of 8bit, since that would make the
top-level CTE a lie.  A sub-part *could* have a CTE of base64 or
quoted-printable, though.

> #2: I thought one of the foundational NNTP/SMTP requirements was that
> every line in the head of a message contains a COMPLETE header (i.e.
> multiple headers on 1 line is not allowed; nor is a header allowed to
> span more than 1 line).  How is it that the MIME Content-Type header
> sometimes violates this as per this example:
> http://groups.google.com/groups?selm=404593c5%40e-post.inode.at&output=gplain

NNTP/SMTP don't say anything about the structure of headers.  You want to
see RFC 2822 instead.  What you're seeing there is a continuation line,
which is valid.  Any line following a header that begins with whitespace
is taken to be a continuation of that header, and there are explicit rules
in RFC 2822 for how to semantically interpret such headers.

> I am thinking of adding code to handle this case that looks for a
> continuation of value clauses on the next line if the current line ends
> in a ';' but for which headers should this be done (obviously not for
> headers such as "From:" and "Subject:")?

Any header can be continued.  That's not the right thing to look for; you
instead want to look for a line beginning with whitespace.  See RFC 2822
for the details.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

          Please post questions rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Technical Details
Message-ID: <87d67lbzqn.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.mail.mime.mbox.zip!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail
References: <86a40a7d.0403091047.6b10611a@posting.google.com>

Show Full Headers
Complete Article Headers
Message-ID: <87d67lbzqn.fsf@windlord.stanford.edu>
Subject: Re: MIME peculiarities (C-T and C-T-E); help please!
Date: Tue, 09 Mar 2004 11:13:20 -0800
From: Russ Allbery <rra@stanford.edu>
References: <86a40a7d.0403091047.6b10611a@posting.google.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.mail.mime.mbox.zip!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail
Newsgroups: news.software.nntp,comp.mail.mime
Organization: The Eyrie
Lines: 64
NNTP-Posting-Host: windlord.stanford.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.Stanford.EDU 1078859601 28175 171.64.19.147 (9 Mar 2004 19:13:21 GMT)
X-Complaints-To: news@news.stanford.edu
User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Common Lisp, linux)
Cancel-Lock: sha1:AhMOlY2yg+kerGJCjc3ENWZKHjM=