lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> > I seem to remember somebody here asking for a mime parsing lib.
> I did. Ended up writing my own :P

Ah, so did I :)

> http://dev.alt.textdrive.com/browser/HTTP/MIME.lua
> 
> > There is one in the Tethys SMTP server in tethys2.util.MIMEMail.
> > There are barely any comments and docs but it might still be useful.
> 
> Here is an usage example of MIME.lua:
> 
> -- Parsing a 'multipart/form-data'
> 
> local MIME = require( 'MIME' )
> local aMIME = MIME( aContent )
> 
> for anIndex, aValue in ipairs( aMIME.content ) do
>      print( anIndex, aValue )
> end

At first I did not understand why it was not correctly parsing my test file.
And then I realized I had it in unix line feeds instead of DOS ones.
I know DOS ones are the standard but I made my parser specifically ignore
that because I need to understand the most possible number of mails and yes
sometimes I get some in unix line feeds.

Also mime works on a table nistead of a string, a string is more natural
but since I'm doing many string operations on the message having it broken
down by lines makes for better performances (and ease of use when I add
new lines in between). But then that is derived from Tethys needs rather
than being specific to the MIME parsing(altough having them by line
helped greatly).

Your lib seems to handle formdata while mine does not (truly rare to receive
a formdata encoded email I suppsoe ;> ) but it does not decode bodies.
At least not my quoted-printable test with split long lines.

What do you use MIME parsing for in Nanoki?

Anyway nice lib you've made, at least it is better documented than mine ;>

-- 
DarkGod <darkgod@t-o-m-e.net>