🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #46525

Re: Encoding binary data

#46525
From: Curt Welch
Date: Fri, 19 May 2000 00:00
71 lines
4082 bytes
Russ Allbery <rra@stanford.edu> wrote:
> Anne Wilson <anne@unidata.ucar.edu> writes:
> > Andrew Gierth wrote:
>
> >> As far as NNTP is concerned, the limits on data are:
> >>
> >>   - no NUL characters (many implementations choke on them)
> >>
> >>   - CR+LF should occur only together and only as a line terminator
> >>     (some implementations convert line endings to local format on
> >>     reception, this usually results in bare LFs being converted to
> >>     CR+LF on transmission)

That's not a real technical NNTP limit.  That's a practical USENET limit.
The only real NNTP limit is that the last two bytes of the article must be
CR LF.

> > Sorry - I don't follow the "only as a line terminator" part.  If CRLF
> > should occur in my binary file, is that a problem?

On some systems it's a problem but not on NNTP.  The problem is that some
systems see that CR LF, and then convert it to the local "END OF LINE"
format.  On a Unix system that converts the article to local text file
format, the CR LF would be changed to a LF.  And then, a local program
on _that_ system might try to read the "text file" version of the article.
To it, the binary would be corrupted.

But if you only use NNTP news readers to read the article (which for sure
is the most common today), that same server would translate the LF back
to a CR LF before sending it out, and it would look fine.

But, then the problem becomes a lone LF in your binary.  When that gets
stored and re-transmitted, it gets turned into a CR LF, and once again,
your binary is corrupted.

Newer news servers avoid all this by not converting the articles when
they are saved.  They save them in raw NNTP format (wire format as it's
commonly called), so when it's read back by a newsreader, the LFs,
and CRs, and CR LFs, are all preserved correctly, and for those, you can
actually get away with using raw binary formats in articles.

> Yes.  You're going to need to do some sort of encoding at least to avoid
> the sequence CRLF.CRLF in the body of the message (normally dot-stuffing
> is used),

dot-stuffing is _required_, not just _normally used_.

When the article is sent with NNTP, the end of the article is marked
with a line that contains a single dot.  i.e. the 5 byte sequence:

  CR LF DOT CR LF.

So, to prevent a line like that in an article (or hidden in a binary)
from fasely marking the end of the article, all "CR LF DOT" sequencies
must be converted to "CR LF DOT DOT" when the article is transmitted
over NNTP (execpt if course the trailing dot which is sent as the marker
for the end of the article).

On many of the new news servers, you can send raw binary (with the correct
dot stuffing) and it works fine.

On Usenet, you will always have to assume that some servers out there
won't deal with NULLs, or lone CR, or lone LFs, in the articles.  And
you should also assume that some servers will have problems with "long
lines" -- i.e. many thousands of bytes between pairs of CR LFs.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/

Technical Details
Message-ID: <20000519124008.263$A6@newsreader.com>
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!not-for-mail
References: <3921BBF8.F251A540@unidata.ucar.edu> <87bt2511sn.fsf@erlenstar.demon.co.uk> <3924568F.463ADE1@unidata.ucar.edu> <yl8zx7m4tm.fsf@windlord.stanford.edu>

Show Full Headers
Complete Article Headers
Message-ID: <20000519124008.263$A6@newsreader.com>
Subject: Re: Encoding binary data
Date: Fri, 19 May 2000 00:00:00 +0000
From: curt@kcwc.com (Curt Welch)
References: <3921BBF8.F251A540@unidata.ucar.edu> <87bt2511sn.fsf@erlenstar.demon.co.uk> <3924568F.463ADE1@unidata.ucar.edu> <yl8zx7m4tm.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!not-for-mail
X-Deja-AN: 625465757
X-User: Curt@NewsReader.Com
X-Face: "p}G*1KH{+F7EYGKLb>ogDguabZ+%,?^epeFB!nzu`)`$=QcvL1KF6<0GH!Tbc!Sqo[|tV5 %IW48mQf3K=Ci&gZ7]]aazx@]Y-nq!r5{yH/#,?@lDdUDvOfByB2hVW0.@OM%{l/{cT'{w
Organization: NewsReader.Com
X-Url: http://CurtWelch.Com/
User-Agent: NewsReader.Com
Newsgroups: news.software.nntp