🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #63380

Re: yEnc decoding implementation

#63380
From: Russ Allbery
Date: Mon, 20 Jan 2003 02:32
168 lines
10665 bytes
Russ Allbery  <rra@stanford.edu> wrote:

> Jeremy already wrote a description of how to use yEnc as part of MIME.
> While walking into work today, I worked out what I think would work as
> a transition plan from where you are right now to yEnc as a CTE and as
> a new Content-Type for multipart binaries.

And here is that.

First, I'll present my original idea, and then note a variation that
Kjetil raised on multipart handling and that is an excellent point.  The
multipart handling is the main part that I think could benefit from some
review by the e-mail MIME experts, as there are a variety of places in
which one could stash the information for multiparts and it's inobvious to
me which place is best.

 1. Specify a new Content-Transfer-Encoding named x-yenc-combined.  The
    specified decoding for that CTE is exactly the same as a yEnc post is
    currently, including not changing any of the content not enclosed
    between =ybegin/=yend.

    This isn't a clean MIME CTE, and isn't suitable for standardization,
    since there is still structure contained in the message that's being
    hidden by the CTE.  It approaches a real CTE, though, if you define
    only those things between =ybegin/=yend as being the real content of
    the message and specify that a decoder should ignore all other content
    in the message.  It's close enough for the initial step.

    The reason for this step is to be able to label yEnc posts (either
    single-part or multipart; this CTE is suitable for either) right away
    without having to change a single other thing about how they're
    generated or decoded, thereby immediately taking advantage of the MIME
    policy for handling unknown CTEs (namely treating anything with an
    unknown CTE as an application/octet-stream opaque object regardless of
    its Content-Type, which is exactly what you want readers that don't
    understand yEnc at all to do since you can then send the body of the
    post to an external decoder).

 2. Begin tagging all yEnc posts with CTE: x-yenc-combined, both
    single-part and multipart.  Obviously this will take some time as
    software is updated, but it also doesn't hold up the additional steps.
    As this is done, there's now a fool-proof way of identifying yEnc
    posts, and once the yEnc posts so-tagged reaches a critical
    percentage, news reader behavior can change so that *by default* no
    attempt is made to find =ybegin lines in posts that aren't tagged with
    this CTE.  This takes care of the false-detection problem.

 3. Specify a new CTE named x-yenc.  This is the pure CTE; in other words,
    there would be no need for =ybegin or =yend lines in parts encoded
    with this CTE.  This is just a pure CTE using the yEnc encoding rules.
    However, it would have written into its specification that any lines
    starting with =ybegin, =yend, or =ypart would be ignored when decoding
    (perhaps all lines beginning with "=" -- I forget the yEnc spec here),
    and to start with, all encoders should include the =ybegin/=yend
    lines.

 4. Start posting *single-part* binaries using a CTE of x-yenc.  Note that
    *no text* is allowed in a part with that CTE.  This means that if the
    entire message is just the binary, the CTE: x-yenc can be put in the
    main headers of the article.  If there is a text description, the
    message should be posted as multipart/mixed like any other MIME
    message with a text portion and a binary portion (carrying its own CTE
    of x-yenc).

    line=, size=, and name= information should be included in a =ybegin
    line, but it should *also* be included in the appropriate MIME headers
    so that MIME clients can take advantage of that information.  In
    particular, the name= should be specified as the filename argument of
    a Content-Disposition header, and Content-MD5 should be used for an
    integrity check of the message.  line= seems relatively unimportant to
    lift into the main headers.

    size= poses a minor challenge, as Content-Length means something else.
    One approach would be to let the decoder notice the =ybegin line and
    use the size value there if it wants to check for truncation; that's
    actually not that bad of an approach, since a length check could
    reasonably be thought of as part of the encoding and decoding process
    (after all, consider the length bytes at the beginning of every line
    of a uuencode message).  Note that length is a bad substitute for an
    integrity check; if the Content-MD5 header is present and verified,
    that will catch far more problems, at the cost of not allowing one to
    detect a truncated message until one finishes downloading it (but how
    often is a message truncated, really?).

 5. At this point, transition to MIME for single-part yEnc binaries is
    *done*.  That's all there is to it.  yEnc can immediately make use of
    internationalization of file names per the MIME standards and a
    stronger checksum, and the Content-Type of the yEnc part can be
    accurate and used by the decoder to know the type of the resulting
    file without having to play guessing games with the extension.

 6. Specify a new MIME type for fragments of files.  This is exactly the
    same as was proposed by Jeremy Nixon; in fact, I'd just use his
    specification at:

        <http://www.exit109.com/~jeremy/news/binaries/multipart.html>

    except that I think the file name should stay in Content-Disposition
    since I don't think having the file name in the same header actually
    is to much advantage.  This carries all of the information that the
    =ypart infrastructure would carry, in a friendlier way (and with a
    unique ID separate from the file name, which solves some problems in
    figuring out how to glue things back together).

 7. Start using this Content-Type for parts of a multipart file, with a
    CTE of x-yenc as above.  Note that this doesn't break anything for
    existing yEnc decoders, since the format of the body of the message
    still matches what they expect, and there are substantial advantages
    for MIME-aware readers.  The Content-Type line can be easily handled
    by duplicating the information from the =ybegin/=ypart lines into the
    header and also generating a unique ID for each complete binary (xBin
    could be used here to generate the ID).

 8. Somewhere far, *far* down the road, encoders can drop the
    =ybegin/=yend lines from encoded parts because nothing is using them
    any more (unless the size= part of =ybegin proves useful and doesn't
    have a good MIME translation).  This can be delayed basically forever
    if needed.

That's all there is to it.  Note that no step of this evolution breaks any
existing yEnc implementations unless an unknown CTE confuses them (and if
it does, that's easy enough and even trivial to fix, and there's a lot of
advantage to this approach for the news reader author in avoiding false
positives down the road, so there's advantage to them to fix this).  It
certainly shouldn't break the transparent proxy method, or any external
decoder, and it will actually make it easier to use external decoders
since an unknown CTE will flag to MIME-aware programs that the body should
be handled by an external program.

Note that you don't have to go through all eight steps.  There are
immediate and significant advantages just from doing steps 1 and 2, since
then at least everything that's yEnc is tagged as such right up front.  In
fact, I think that steps 1 and 2 are worth doing even if you think the
rest of this proposal is a waste of time.

Note also that you can implement the entirety of this proposal without
going through any sort of standards process (except the multipart type
would have to be called application/x-file-fragment).  You're using
private-space names for everything, so there's no need to register or
write any sort of standard.  It would, of course, at some point be good to
standardize all of this and register a real yenc encoding, probably
without the =ybegin/=yend stuff, but that can safely be left for future
work.

Now, Kjetil's suggestion was to add new parameters to Content-Disposition
to handle multipart binaries rather than introducing a new content-type.
I can see some real appeal to this, primarily because adding a new
content-type results in information loss.  Jeremy's content-type has a way
of noting the original content-type so that the implementation can have
that available after decoding, but there isn't anywhere to put any
parameters that were associated with the original content-type.  (It's
also annoying to have an image/jpeg posted with any content-type other
than image/jpeg, even if it's a fragment of an image/jpeg.)

However, the drawback to using Content-Disposition parameters is that a
client that doesn't know about them will just ignore them, which could
result in it trying to feed partial image/jpeg files to a JPEG viewer
rather than realizing that it doesn't have all of them.  Using a separate
content-type avoids that problem.

It would be good to get the advice of some MIME experts on this point.

-- 
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: <ylptqszh2j.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail
References: <PM0003B2ED450C7E1E@minion.nashville.comcast.net> <yladioi1w1.fsf@windlord.stanford.edu> <5727b.31320d@archiver.winews.net> <ylof6xyaj0.fsf@windlord.stanford.edu>

Show Full Headers
Complete Article Headers
Message-ID: <ylptqszh2j.fsf@windlord.stanford.edu>
Subject: Re: yEnc decoding implementation
Date: Sun, 19 Jan 2003 18:32:52 -0800
From: Russ Allbery <rra@stanford.edu>
References: <PM0003B2ED450C7E1E@minion.nashville.comcast.net> <yladioi1w1.fsf@windlord.stanford.edu> <5727b.31320d@archiver.winews.net> <ylof6xyaj0.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail
Newsgroups: news.software.nntp
Organization: The Eyrie
Lines: 167
NNTP-Posting-Host: windlord.stanford.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.Stanford.EDU 1043029972 9098 171.64.13.23 (20 Jan 2003 02:32:52 GMT)
X-Complaints-To: news@news.stanford.edu
User-Agent: Gnus/5.090008 (Oort Gnus v0.08) XEmacs/21.4 (Honest Recruiter,
 sparc-sun-solaris2.6)
Cancel-Lock: sha1:fq07PrEY/sqNV03Iy0G3H52uyDI=