MHonArc Resource List

MIMEFILTERS


Syntax

Envariable

N/A

Element

<MIMEFILTERS>
filter-specification
...
</MIMEFILTERS>

Command-line Option

N/A


Description

The resource MIMEFILTERS is used to hook in user specifed filters into MHonArc. The MIMEFILTERS resource can only be set via the MIMEFILTERS element. The syntax for each line of the the MIMEFILTERS element is as follows:

content-type:routine-name:file-of-routine

The definition of each colon-separated value is as follows:

content-type

The MIME content-type the filter processes. An explicit content-type (base/subtype) or a base content-type (base/*) can be specified.

routine-name

The actual routine name of the filter. The name should be fully qualified by the package it is defined in (e.g. "mypackage'filter").

NOTE

Package qualification must use Perl 4 syntax. The '::' qualification is not supported, yet.

file-of-routine

The name of the file that defines routine-name. If the file is not a full pathname, MHonArc finds the file by looking in the standard include paths of Perl, and the paths specified by the PERLINC resource.

Any whitespace is stripped out before processing.

Writing Filters

If you want to write your own filter for use in MHonArc, you need to know the Perl programming language. The following information assumes you know Perl.

Function Interface of Filter

MHonArc interfaces with MIME filters by calling a routine with a specific set of arguments. The prototype of the interface routine is as follows:

sub filter {
    local($head, *fields, $data, $decoded, $argstring) = @_;

    # Filter code here

    # The last statement should be the return value, unless an
    # explicit return is done. See the following for the format of the
    # return value.
}
Argument Descriptions
$head

This is the header text of the message (or body part if called in a multipart message).

*fields

A pointer to an associative array that has broken down $head into field label/field value components. The keys are the lower-case representations of the field values. Example: If you would like to retrieve the value of the Content-Type field, then use the following: $fields{`content-type'}.

If a field occurs more than once in a header, MHonArc separates the field values in the associative array by a `\034' character. To make your filter less likely to break due to changes in MHonArc, you may use the $readmail'FieldSep variable instead of `\034'.

$data

This is a copy of the message (or body part if called in a mulitpart message) body.

$decoded

This flag is set to 1 if MHonArc decoded the message and $data represents the orginal data before encoded by the sender. If set to 0, $data has not been decoded. The failure to decode occurs if MHonArc does not recognizeed the encoding specified in the Content-Transfer-Encoding field.

MHonArc has decoded the data for you if it was encoded in 7-Bit, 8-Bit, Binary, Quoted-Printable, Base64, Uuencode (x-uuencode, uuencode, x-uue, uue).

$argstring

This is an optional argument string that may be used to modify the behavior of the filter. The format of this string is determined by the filter itself. The value of the string is set by the MIMEARGS resource.

Return Value

The return value is treated as an array. The first item in the array is a string representing the HTML markup to insert in the HTMLized message. An empty string may be returned to tell MHonArc that the routine was unable to filter data.

Any other array items are treated as names of any files that were generated by the filter. MHonArc needs to keep track if any extra files that a filter may generate in order for MHonArc to delete those files if the message gets removed from the archive.

NOTE

If the filter creates a subdirectory with files, the filter only needs to return the subdirectory in the return list. If the message gets removed, MHonArc will delete the entire directory.

Filter Writing Tips

The following recommendations/tips are given to help you write filters:

Using C

If a MIME filter requires the utilization of a C program, or other non-Perl executable, a Perl wrapper must be written for the program in-order to interface with MHonArc.


Default Setting

<MIMEFilters>
application/*:m2h_external'filter:mhexternal.pl
application/x-patch:m2h_text_plain'filter:mhtxtplain.pl
audio/*:m2h_external'filter:mhexternal.pl
image/*:m2h_external'filter:mhexternal.pl
message/partial:m2h_text_plain'filter:mhtxtplain.pl
text/*:m2h_text_plain'filter:mhtxtplain.pl
text/html:m2h_text_html'filter:mhtxthtml.pl
text/plain:m2h_text_plain'filter:mhtxtplain.pl
text/richtext:m2h_text_plain'filter:mhtxtplain.pl
text/setext:m2h_text_setext'filter:mhtxtsetext.pl
text/tab-separated-values:m2h_text_plain'filter:mhtxtplain.pl
text/x-html:m2h_text_html'filter:mhtxthtml.pl
text/x-setext:m2h_text_setext'filter:mhtxtsetext.pl
video/*:m2h_external'filter:mhexternal.pl
</MIMEFilters>

The following describes the behavior of each filter.

m2h_external'filter

The filter extracts the data into a separate file and puts a hyperlink to the file into the HTMLized message.

By default, the filter ignores any filename specification given in the message when writing the data to disk. A unique filename with an extenstion based upon sub-type is generated.

m2h_external'filter can take the following arguments:

inline

Inline image data by default if content-disposition not defined.

ext=ext

Use ext as the filename extension. The filter already has a large list of extensions for various content-types. Only use this argument if you process a content-type not recognized by the filter.

type="description"

Use "description" as type description of the data. The double quotes are required. The filter already has a large list of descriptions for various content-types. Only use this argument if you process a content-type not recognized by the filter.

subdir

Place derived file in a subdirectory of the archive. The subdirectory will be called "msgMSGNUM.dir". This option may be useful if usename is specified to avoid security and name conflict problems.

usename

Use (file)name attribute for determining name of derived file. Use this option with caution since it can lead to filename conflicts and security problems.

All arguments should be separated by at least one space.

The following table shows the default list of content-types, with descriptions, m2h_external'filter recognizes:

Content-typeDescription
application/astoundAstound presentation
application/fastmanfastman file
application/mac-binhex40Mac BinHex file
application/mbedletmbedlet file
application/mswordMS-Word document
application/octet-streamBinary data
application/odaODA file
application/pdfPDF file
application/pgpPGP message
application/pgp-signaturePGP signature
application/postscriptPostScript document
application/rtfRTF file
application/sgmlSGML document
application/studiomStudio M file
application/timbuktutimbuktu file
application/vnd.ms-excelMS-Excel file
application/vnd.ms-powerpointMS-Powerpoint file
application/vnd.ms-projectMS-Project file
application/winhlpWinHelp document
application/wordperfect5.1WordPerfect 5.1 document
application/x-NET-InstallNet Install file
application/x-asapasap file
application/x-bcpioBCPIO file
application/x-cpioCPIO file
application/x-cshC-Shell script
application/x-dotdot file
application/x-dviTeX dvi file
application/x-earthtimeEarthtime file
application/x-envoyEnvoy file
application/x-excelMS-Excel Spreadsheet
application/x-gtarGNU tar file
application/x-hdfHDF file
application/x-javascriptJavaScript source
application/x-kshKorn Shell script
application/x-latexLaTex document
application/x-makerFrameMake document
application/x-mifFrame MIF document
application/x-mochamocha file
application/x-msaccessMS-Access database
application/x-mscardfileMS-CardFile
application/x-msclipMS-Clip file
application/x-msmediaviewMS-Media View file
application/x-msmetafileMS-Metafile
application/x-msmoneyMS-Money file
application/x-mspublisherMS-Publisher document
application/x-msscheduleMS-Schedule file
application/x-msterminalMS-Terminal
application/x-mswriteMS-Write document
application/x-netcdfCdf file
application/x-ns-proxy-autoconfigNetscape Proxy Auto Config
application/x-patchPatch file
application/x-perlPerl source
application/x-pointpluspointplus file
application/x-salsasalsa file
application/x-scriptA script file
application/x-shBourne shell script
application/x-sharShar file
application/x-spritesprite file
application/x-sv4cpioSV4Cpio file
application/x-sv4crcSV4Crc file
application/x-tarTar file
application/x-tclTcl script
application/x-texTeX document
application/x-texinfoTeXInfo document
application/x-timbuktutimbuktu file
application/x-tkinedtkined file
application/x-troffTroff document
application/x-troff-manTroff manpage
application/x-troff-meTroff ME
application/x-troff-msTroff MS
application/x-ustarUStar file
application/x-wais-sourceWAIS Source
application/zipZip archive
audio/basicBasic audio
audio/echospeechEchospeech audio
audio/midiMIDI audio
audio/x-aiffAIF audio
audio/x-epacepac audio
audio/x-midiMIDI audio
audio/x-pacpac audio
audio/x-pn-realaudioPN Realaudio
audio/x-wavWave audio
image/bmpWindow bitmap
image/cgmComputer Graphics Metafile
image/fifFIF image
image/gifGIF image
image/iefIEF image
image/ifsIFS image
image/jpegJPEG image
image/pngPNG image
image/tiffTIFF image
image/vndVND image
image/waveletWavelet image
image/x-bmpWindows bitmap
image/x-cmu-rasterCMU raster
image/x-pbmPortable bitmap
image/x-pcxPCX image
image/x-pgmPortable graymap
image/x-pictMac PICT image
image/x-pnmPortable anymap
image/x-portable-anymapPortable anymap
image/x-portable-bitmapPortable bitmap
image/x-portable-graymapPortable graymap
image/x-portable-pixmapPortable pixmap
image/x-ppmPortable pixmap
image/x-rgbRGB image
image/x-xbitmapX bitmap
image/x-xbmX bitmap
image/x-xpixmapX pixmap
image/x-xpmX pixmap
image/x-xwdX window dump
image/x-xwindowdumpX window dump
text/htmlHTML document
text/plainText document
text/richtextRichtext document
text/setextSetext document
text/sgmlSGML document
text/x-htmlHTML document
text/x-setextSetext document
text/x-speechSpeech document
video/isivideoisi video
video/mpegMPEG movie
video/msvideoMS Video
video/quicktimeQuickTime movie
video/vivovivo video
video/waveletWavelet video
video/x-msvideoMS video
video/x-sgi-movieSGI movie

m2h_text_html'filter

This filter is designed to process text/html or text/x-html messages. The filter must modify the HTML for merging into the final filtered HTML messages. Modification is needed so the resulting filtered message is valid HTML.

m2h_text_plain'filter

This filter is designed to process text/plain messages and messages with no MIME information. The filter is also used to process text messages of an unknown subtype.

The default behavior of the filter is wrap the data in the HTML PRE element and escape special characters. It will also convert text that looks like a URL into a hyperlink. If the data contains non-ASCII character, the filter will convert the characters to the appropriate entity reference.

m2h_text_plain'filter can take the following arguments:

asis=set1:...

Colon separated lists of charsets to leave as-is. Only HTML special characters will be converted into entities.

keepspace

Preserve all spaces if the nonfixed option is specified. Each space will be translated to a &nbsp; entity reference.

maxwidth=#

Force the maximum width of lines to be # characters in length. Any lines longer than # characters will be wrapped.

nonfixed

Do not wrap message text in the HTML PRE element. This will cause text to be rendered in the default font (which is normally proportionally spaced). Each line of the message will have a <BR> appended in order to preserve the line representation of the message.

nourl

Do not hyperlink URLs.

quote

Italicize quoted message text.

All arguments should be separated by at least one space.

m2h_text_setext'filter

This filter converts text/setext and text/x-setext messages to HTML.


Resource Variables

N/A


Examples

None.


Version

1.0


See Also

MIMEARGS, PERLINC


97/05/13 17:29:38
MHonArc
Copyright © 1997, Earl Hood, ehood@medusa.acs.uci.edu