🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #59986

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

#59986
From: Juergen Helbing
Date: Thu, 22 Aug 2002 05:19
194 lines
8490 bytes
"Andy H" <andyh@nospam.com> wrote:

>> Google for Binaries ?  <giggle>
>
>That's EXACTLY what I'm trying to accomplish!

I wouldbe really curious how long such a site would survive.

>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.  

There are the "keywords" or "keyword lines".
However be prepared for erroneous detections.
There are even people sending out text-messages
with 'faked' begin & =ybegin keywords for fooling
neticens.

It would be necessary to scan very exactly.

>How do you handle posts in which there is an
>unknown amount of plain text typed before the =ybegin, 

Plain text in front of 'begin' or '=ybegin' lines are usually
comments (or ads).
Such comments are often used in reply-messages (Re:)
to inform the users about the content.
Some newsreaders are generating such comments as
(0/1) sections (an own message) followed by the binary
(1/1) in another message. But other newsreaders permit
to 'mix' text with binaries.

Usually for a database it might be a good idea to add 
the prefix text to the fulltext database.

>or even multiple
>attachments in the same post! <shudder>

Multiple attachments are happening very often with
Uuenc and Mime/Base64 - seldom with yEnc.
And you should be prepeared for more 'multi-binaries.

Some people are even sending out 10 pictures in 
a multipart which contains of 3 parts.

The "message-composition" windows and features
of the newsreaders are very complex.

In case of "multi-binaries' within one (or a multipart)
message there is not enough room to have all the
filenames in the subject lines. And they are hard
to recognize automatically.

>> 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.  

You said in your reply that you want something as "Google for Binaries".
If you want to offer a user a "binary survey" for a group before he
starts then you need all filenames and binary info. And because this
info is 'hidden' in the bodies you need the full articles.

>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.  

This sounds reasonable - and it is a nice trick to use the news-server
itself for seeking in the header fields.

In this case you neither need a full XOVER nor the bodies.

>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.

This is basically right.

>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?

Multiparts give you the additional fun that there are "trailers" or "headers"
even in (2/n) (3/n).... (n/n) sometimes.

Prominent examples are:
BEGIN ----- cut here -----
END ----- cut here ----

and

<headers>
   <empty line>
   <funny header text>
   <empty line>
   <Data Part>
   <empty line> 
   <funny trailer text>

In case of 'UUencode' you will scan for a line which matches
the UUenc method (1. char = lengt of line)....
This is sometimes very tricky to write - especially for the last
segment of a multipart where the Uuenc line does not start with 
the "usual" [M].

>> 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?  :-)  

As long as you are creating a tool for individual users I see no problems.
Already today all newsreaders permit to fetch millions of headers and
to perform a textual search on them.

This becomes only critical if you offer a site which offers a survey
for the entire binary usenet.

>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).  

I believe you can publish your program.
After reading your further spec it reminds me stronlgy
to "GrabIt".

>By the way,
>I am writing this tool in java so that people on other platforms (LINUX,
>Solaris) will be able to use it.

Choosing a platform independent language is wise today.
It will become a very interesting project.

>> 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.

I want to recommend that you subscribe to some of these
services (see:  alt.binaries.news-server-comparison) and
get some ideas about the GUI, the functionality and the
amount of work.
Even for "private projects" it is a nice idea to gather as much
info and spec as you can _before_ you start coding or 
publishing.

The biggest evil for all kind of programming is lack of proper
spec and forseeable problems and features. The danger 
of creating a tool which "fundamental principles" are not
powerful enough results in enormous maintenance work.
This especially applies to the database-design, the used
directory structure, archiving and expiry.

It might be also a good idea to "try" some of the popular
"binary downloading" tools which do a similar job.
Most of them offer a free trial version which gives you 
a better survey to the existing "solution-base" - and perhaps
shows you that your idea is innovative (or an already
invented wheel)....
A good list of tools is available at  www.yenc.org in the 
windows section.

Welcome to the community of binary usenet programmers.
Lots of Fun ahead !

CU
-- 
Juergen

Technical Details
Message-ID: <09197.m82201@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!upp1.onvoy!onvoy.com!news-out.visi.com!hermes.visi.com!news.alt.net!usenet
References: <um4up98ldl41dd@news.supernews.com> <5717n.k82200@archiver.winews.net> <um7j45ia9bfl55@news.supernews.com>

Show Full Headers
Complete Article Headers
Message-ID: <09197.m82201@archiver.winews.net>
Subject: Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
Date: Thu, 22 Aug 2002 05:19:09 +0000
From: archiver@i3w.com (Juergen Helbing)
References: <um4up98ldl41dd@news.supernews.com> <5717n.k82200@archiver.winews.net> <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!upp1.onvoy!onvoy.com!news-out.visi.com!hermes.visi.com!news.alt.net!usenet
Newsgroups: news.software.nntp
Organization: Altopia Corp. - Usenet Access - http://www.altopia.com
Lines: 193
X-Newsreader: MyNews