🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #59976

Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?

#59976
From: Andy H
Date: Wed, 21 Aug 2002 17:23
145 lines
7135 bytes
First off thank you for the HELPFUL response, Juergen.

"Juergen Helbing" <archiver@i3w.com> wrote in message
news:5717n.k82200@archiver.winews.net...
> "Andy H" <andyh@nospam.com> wrote:
>
> >I am in the process of writing an NNTP search tool (much like the now
> >defunct NewsFerret) which will allow one to search through headers by
> >subject on the NNTP server (rather than having to download hundreds of
megs
> >of headers and search on the client).
>
> Good luck.
>
> >Obviously I want to add attachment
> >processing to this tool to allow binary attachment downloading.
>
> Google for Binaries ?  <giggle>

That's EXACTLY what I'm trying to accomplish!

> >Being new
> >to this, I am wondering if there is a primer or any sort of documentation
> >for the various possible encoding schemes as well as a way I can
determine
> >which one is being used.
>
> Actually these encodings are used for binaries (sorted by relevance):
>
> UUencode  (see UUdeview library)
> yEncode   (see  www.yenc.org)
> MIME+Base64  (see RFCs .... ).
> BinHex (Mac Specific ?)
>
> >Browsing some msgs, I do not see any specific
> >header fields which say anything about the encoding, so I am assuming
> >everything is in the body.
>
> Some very basic compositions of MIME contain the
> Content-Transfer-Encoding in the message headers.
>
> Complex MIME compositions and all other encodings can be found
> in the body.
>
> UUenc is usually detected with a line as:
>    begin ### filename   (where ### is 644 of 664 or and digits).
>
> yEnc is pretty good detected with a line as:
>    =ybegin <space>
>
> MIME/base64 is detected by 'Content-Transfer-Encoding'
> within the MIME structure.
>
> BinHex is (sometimes) detected by the text:
>    "This .... must be decoded with BinHex 4.0"
>    (or so..... I never found a reliable way to detect it properly).
>
> There are some people who want to make Binary Detection
> easier by adding MIME headers to the OVERVIEW data
> of news-servers. But this would help only if the entire
> Binary Usenet posting structure would be changed -
> and then it would be necessary to convince people
> that they want such a feature (see also below: 'Second').

Thanks for the great overview.  I have gotten the MIME/base64 encodings
working for the most part, now the next task is to determine the other types
which are present in the body.  How do you handle posts in which there is an
unknown amount of plain text typed before the =ybegin, or even multiple
attachments in the same post! <shudder>

> >Any help or direction would be greatly
> >appreciated.  Thanks in advance!
>
> There are two reasons why your work is difficult:
>
> First you really need to download the FULL message stream.
> You cant even 'stop' fetching a message after finding a filename
> and/or encoding - because NNTP delivers always complete bodies
> or articles. So you need a _lot_ of computing power for 300 Gigs/day.
> Or you 'break' the connection all the time - and need lots of
> time for reconnect (or a bunch of parallel tasks).

I'm a little confused by this paragraph.  I don't think I need hardly any
computing power for this.  Basically I have a GUI with two fields which take
user input: wildcarded group to search, and then wildcarded subject (maybe
I'll add search by author later).  I then get all the matching groups from
the server (LIST ACTIVE), select each group one at a time (GROUP), and use
XPAT to search for the matching subject headers.  I present this as a list
to the user.  Only when the user selects an article and requests to download
it do I start the mess of determining whether or not there is an attachment
and what type.  I would not get any bodies automatically.  Here's my initial
thoughts on how I would determine the article's encoding scheme:

1) ARTICLE command, reading first the headers up until the blank linke to
see if there are MIME headers (which would usually indicate base64)
2) continue reading from socket a line at a time, carefully looking to try
and determine the encoding scheme, while writing body lines to a temp file
for later decoding.
3) once finished writing to the temp file (and presumably after determining
the encoding type), run the approciate decoder on the temp file.

Of course, I have skipped the part dealing with multiple part msgs, but that
is mainly tedious subject pattern matching and article body concatination,
and I can always provide a manual 'manually select msgs and decode in user
order' function for backup.   Am I missing something obvious?

> Second nobody really wants to know which binaries are really posted
> all the time to Usenet. The few poor attempts from 'authorities' to
> do it resulted already in filenames as:
> "Am I The Only One Who Is Working Here.mpg"   for a well known movie.
> And this would not help you any further than today....  :-))

You raise a really good point here which I hadn't considered.  I wonder if
adding a 'no commercial or government use' condition in the license
agreement would help?  :-)  Or maybe I will do as you've done and keep this
tool to myself (that's the main reason I'm writing it anyway).  By the way,
I am writing this tool in java so that people on other platforms (LINUX,
Solaris) will be able to use it.

> As a "Binary Usenet Developer" I am running the tool you want
> - for a few test groups. But this is my very personal pleasure...

I envy you. :-)

> There is a bunch of "Web-Usenet-Servers" out there.
> This are NNTP-Servers with an HTTP FrontEnd for
> user's convenience. They are doing a similar job and
> I can imagine that their programmers worked hard
> on them - and are in constant process of development.

Unfortunately, I don't think my news service provides this.

> If you dont want to create your own commercial News-Service
> then it might be better to use their functionality as a user.
>
> HTH
> --
> Juergen
>
>
>
>


Technical Details
Message-ID: <um7j45ia9bfl55@news.supernews.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!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!newsfeed.news2me.com!sn-xit-05!sn-xit-06!sn-post-01!supernews.com!news.supernews.com!not-for-mail
References: <um4up98ldl41dd@news.supernews.com> <5717n.k82200@archiver.winews.net>

Show Full Headers
Complete Article Headers
Message-ID: <um7j45ia9bfl55@news.supernews.com>
Subject: Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
Date: Wed, 21 Aug 2002 11:23:20 -0600
From: "Andy H" <andyh@nospam.com>
References: <um4up98ldl41dd@news.supernews.com> <5717n.k82200@archiver.winews.net>
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!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!newsfeed.news2me.com!sn-xit-05!sn-xit-06!sn-post-01!supernews.com!news.supernews.com!not-for-mail
Newsgroups: news.software.nntp
Organization: Posted via Supernews, http://www.supernews.com
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
X-Complaints-To: newsabuse@supernews.com
Lines: 144