🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
10 messages
10 total messages Started by Andy H Tue, 20 Aug 2002 17:23
Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#59958
Author: Andy H
Date: Tue, 20 Aug 2002 17:23
16 lines
1708 bytes
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).  Obviously I want to add attachment
processing to this tool to allow binary attachment downloading.  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.  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.  Any help or direction would be greatly
appreciated.  Thanks in advance!

Andy


Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#59962
Author: Juergen Helbing
Date: Tue, 20 Aug 2002 21:17
98 lines
4121 bytes
"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>

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


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


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


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


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.

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




Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#59964
Author: Jeffrey M. Vinocur
Date: Tue, 20 Aug 2002 21:50
33 lines
2314 bytes
In article <um4up98ldl41dd@news.supernews.com>,
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).

You realize some clients allow downloading of just the headers
first?


>Obviously I want to add attachment
>processing to this tool to allow binary attachment downloading.  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.  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.  Any help or direction would be greatly
>appreciated.  Thanks in advance!

Two things:

- Read the article at
  http://www.newsreaders.com/misc/twpierce/news/newsreader-manifesto.html
- Search the archives of this group (and news.software.readers, I
  suppose) for discussion about detecting attachments.  It's not
  pretty.


-- 
Jeffrey M. Vinocur
jeff@litech.org
Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#59966
Author: Andy H
Date: Tue, 20 Aug 2002 23:09
56 lines
3109 bytes
See responses inline below...

"Jeffrey M. Vinocur" <jeff@litech.org> wrote in message
news:ajudil$l4t$2@puck.litech.org...
> In article <um4up98ldl41dd@news.supernews.com>,
> 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).
>
> You realize some clients allow downloading of just the headers
> first?

Yes, I do.  In certain high traffic binary groups, the headers alone
(assuming you are using a premium news service with large retention) are
several hundred megs (alt.binaries.sounds.mp3 for example).  I'm not even
talking about the attachments and msg bodies.  Most news services also limit
monthly bandwidth, so you can see how much bandwidth could be saved.  I
think it is unreasonable to have to download hundreds of megs just to search
for an article when there are seemingly unused NNTP server extensions (xpat)
for just this task.

> >Obviously I want to add attachment
> >processing to this tool to allow binary attachment downloading.  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.  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.  Any help or direction would be greatly
> >appreciated.  Thanks in advance!
>
> Two things:
>
> - Read the article at
>   http://www.newsreaders.com/misc/twpierce/news/newsreader-manifesto.html
> - Search the archives of this group (and news.software.readers, I
>   suppose) for discussion about detecting attachments.  It's not
>   pretty.

Thanks for the link, I'll check it out (and the FAQ too).  Ya, I'm quickly
learning that this is a very hairy task indeed.

Andy

>
>
> --
> Jeffrey M. Vinocur
> jeff@litech.org


Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#59976
Author: 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
>
>
>
>


Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#59980
Author: those who know me have no need o...
Date: Wed, 21 Aug 2002 18:09
13 lines
1359 bytes
in news.software.nntp i read:
>"Juergen Helbing" <archiver@i3w.com> wrote in message
>news:5717n.k82200@archiver.winews.net...

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

then you might want to look at drn.

-- 
bringing you boring signatures for 17 years
Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#59986
Author: 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

Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#59993
Author: Russ Allbery
Date: Thu, 22 Aug 2002 13:08
22 lines
2056 bytes
Andy H <andyh@nospam.com> writes:
> "Juergen Helbing" <archiver@i3w.com> wrote:

>> Google for Binaries ?  <giggle>

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

Ignoring the search portion, it's actually pretty straightforward to do
this for most of the traffic (which generally just has one binary per
post; the multipart stuff is the only hard point), easy enough that it's a
common thing for college students to do in their spare time.  I think
there have been a good dozen of those floating around Stanford at various
points in the past.  The real problem is that no one ever shares their
work because, well, the reason why people write them is to automate their
porn collection.

-- 
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.
Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#59995
Author: Brian Edmonds
Date: Thu, 22 Aug 2002 18:23
14 lines
1805 bytes
Russ Allbery <rra@stanford.edu> writes:
>>> Google for Binaries ?  <giggle>
>> That's EXACTLY what I'm trying to accomplish!
> Ignoring the search portion, it's actually pretty straightforward to
> do this for most of the traffic

Yeah.  Back in the early/mid 90s, Peter Philips (at UBC) wrote a web
interface to news that did binary decoding.  He had to shut it down
within a couple weeks.  Even then, when few people had heard of the
internet, much less the web, the sudden spike in university backbone
traffic to the CS web server was unsupportable.

Brian.
Re: Tech Question: How to programmatically determine attachment encoding method (base64, MIME, UUEncode, Yenc)?
#60090
Author: Klaas
Date: Wed, 28 Aug 2002 05:52
32 lines
2725 bytes
After careful consideration, Andy H muttered:

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

Newsreaders that leverage XPAT already exist--see XNews for an example.  
I'm not sure that any currently allow a wildcard secification of the 
group, however.

It would be a lot easier to integrate a feature like that in a newsreader 
that already supports XPAT, because the problems of attatchment 
detection, decoding, multi-parts, etc. will have already been solved.  
Things like multiple server support, multi-threaded, streamed 
downloading, queues, et al. are already done.

It's not the XPAT search which is the difficult part, it is augmenting 
that into a useful binaries downloader.  And if you have acheived that, 
why not add "standard" header retrieval and call it a newsreader?

-Mike




Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads