Commit Graph

64 Commits

Author SHA1 Message Date
Peter J. Holzer 1ada1c3817 Add test program for threading algorithm 2020-04-05 16:21:46 +02:00
Peter J. Holzer 29b5288519 Clean up and include style sheets 2019-10-31 21:22:03 +01:00
Peter J. Holzer b86ae9cb3f Handle div and span elements 2019-06-18 23:14:18 +02:00
Peter J. Holzer c9a336e58f Handle cite attribute 2019-06-18 22:11:23 +02:00
Peter J. Holzer 589a217b1b Handle application/pgp-keys 2019-06-17 20:59:23 +02:00
Peter J. Holzer 3865c5f887 Handle message/delivery-status 2019-05-20 23:59:26 +02:00
Peter J. Holzer 35e8266695 Remove magic number from image attachment templates
I have no idea what 1000 was meant to signify.
2019-05-20 23:26:43 +02:00
Peter J. Holzer 00ad5f864e Fix charset handling for text/html parts 2019-05-20 23:25:49 +02:00
Peter J. Holzer bdb5842d75 Handle image/svg+xml attachments 2019-05-20 23:16:30 +02:00
Peter J. Holzer 5e96a73744 Tolerate decoding errors
Sometimes the charset is just wrong, or it uses a non-standard name. Try
to do something useful in these cases.
2019-05-20 23:06:08 +02:00
Peter J. Holzer b1dbb3d40c Implement format=flowed and fix charset handling for text/plain 2019-05-20 00:32:33 +02:00
Peter J. Holzer 647e93afd5 Implement attachment application/pgp-signature
A detached signature doesn't make much sense in an email, but may happen
because of improper quoting. Or somebody might really want to send a
signature separate from the signed file.
2019-05-12 23:17:17 +02:00
Peter J. Holzer 55a1a1df83 Implement attachment text/x-perl 2019-05-12 23:11:21 +02:00
Peter J. Holzer 10fc5e2f61 Implement attachment application/vnd.oasis.opendocument.text 2019-05-12 23:06:52 +02:00
Peter J. Holzer c9ccb38eb9 Implement attachment application/x-compressed-tar 2019-05-12 22:58:41 +02:00
Peter J. Holzer b5316d056e Implement attachment text/x-c++src 2019-05-12 22:51:45 +02:00
Peter J. Holzer 057eba197e Implement attachment text/x-patch 2019-05-12 22:48:05 +02:00
Peter J. Holzer 308a34e6ca Implement attachment application/x-sh 2019-05-12 22:41:35 +02:00
Peter J. Holzer 9b49c740c6 Implement attachment text/x-java 2019-05-12 22:37:24 +02:00
Peter J. Holzer 709c87658b Implement attachment text/x-python 2019-05-12 22:18:55 +02:00
Peter J. Holzer f3bdaae445 Implement inline image/jpeg 2019-05-12 22:12:12 +02:00
Peter J. Holzer f8f64d3506 Allow cid's in multipart/mixed 2019-05-12 22:06:51 +02:00
Peter J. Holzer c84c517f62 Pass extra parameter to children of multipart/alternative
A structure like this is quite common:

  ─><no description>                    [multipa/related, 7bit, 12K]
   ├─><no description>              [multipa/alternativ, 7bit, 9.0K]
   │ ├─><no description>      [text/plain, quoted, iso-8859-1, 3.7K]
   │ └─><no description>       [text/html, quoted, iso-8859-1, 4.9K]
   └─>2b0063.jpg                          [image/jpeg, base64, 3.3K]

Here the main content of multipart/related isn't the html part, but a
multipart/alternative containing the html part and a text part. The html
part still needs access to the onther content of the multipart/related
part, so we need to pass this through.
2019-05-12 21:37:26 +02:00
Peter J. Holzer a44ff7ee4b Handle some more attachment types (some of them bogus) 2019-04-30 22:15:20 +02:00
Peter J. Holzer 8d78b2ec26 Handle RFC 2047 encoded headers 2019-04-30 21:55:21 +02:00
Peter J. Holzer 54290fb668 Handle application/x-shellscript attachments 2019-04-29 21:22:03 +02:00
Peter J. Holzer 2aadb830cd Handle application/x-bzip2 attachments 2019-04-29 21:18:00 +02:00
Peter J. Holzer 5294100b2c Handle multipart/related
For multipart related we need to be able to reference the other parts
from the root part by content-id, so we need to pass an argument with
the necessary information (imaginatively called "extra") to the render
function. Of course since this is called indirectly, every render
function needs to accept an extra argument, even if only
render_text_html uses it.
2019-03-31 23:48:57 +02:00
Peter J. Holzer 2a3e5622f3 Handle ms-tnef attachments
Like other attachments, just create a download link, don't try to parse
them.
2019-03-31 21:50:08 +02:00
Peter J. Holzer 865579655f Handle GIF attachments
Not sure whether providing a download link for attached images is the
right thing to do - we should probably just display them like inline
images. But we can always change that by a simple change of the
template.
2019-03-31 21:34:40 +02:00
Peter J. Holzer f543dbc5c8 Handle (old style) MS-Word attachments 2019-03-31 21:15:31 +02:00
Peter J. Holzer 08784b70fe Handle Perl attachments 2019-03-31 21:03:03 +02:00
Peter J. Holzer 0db91aaa5f Handle C attachments 2019-03-31 20:51:52 +02:00
Peter J. Holzer b2f56c1660 Handle underline in text/enriched 2019-03-17 22:42:44 +01:00
Peter J. Holzer 8acf092559 Fixed return values of all the new render functions
Oops. I should really check the output of the script, not just whether
it crashes in the expected place.
2019-03-17 22:30:27 +01:00
Peter J. Holzer 45848a73ae Handle multipart types that aren't 2019-03-17 22:24:17 +01:00
Peter J. Holzer b053ab454f Refactor render_body to handle each mime-type in a nested function
This replaces the giant elif cascade with a table lookup. It also allows
me to call one function from another.
2019-03-17 22:17:02 +01:00
Peter J. Holzer 035b4e1002 Limit width of text/enriched
60em is a bit more than 100 characters in the fixed-width font I use so
that should be an acceptable compromise between readability and avoiding
unintended line breaks.

The RFC says that output should use "the maximum available margins", but
that was clearly before large monitors became common.
2019-03-16 21:58:42 +01:00
Peter J. Holzer d5c5368bad Implement more text/enriched tags: nofill, param, ...
Nofill and param are handled specially by the parser. The parser now
also tolerates missing end tags.

Handle quite a few tags on output including some (like color and
fontfamily) that use a param.
2019-03-16 21:53:06 +01:00
Peter J. Holzer a997542cfe Handle image/gif (inline)
Inline images are very similar to attachments: We just want to store
them somewhere and refer to them. But we want to use a different element
(<img> instead of <a>) or more generally, a different template. So we
pass the disposition as an additional argument to save_part and use it
to construct the template name - which gives as a flurry of new
templates.
2019-03-10 23:27:30 +01:00
Peter J. Holzer df7fcb5777 Handle message/news 2019-03-10 22:47:10 +01:00
Peter J. Holzer d32c60a318 Handle plaintext and gzipped attachments 2019-03-04 21:49:46 +01:00
Peter J. Holzer 48fcf768ae "Handle" a detached pgp signature
Don't even ignore it (be sarcastic about it).
2019-03-04 21:23:03 +01:00
Peter J. Holzer 314ccaba48 Handle blockquote element and type attribute 2019-03-04 21:07:18 +01:00
Peter J. Holzer 77d2b87b1e Handle multipart/alternative and application/x-unknown-content-type-scpfile
Strange combination, but the first message with multipart/alternative
also contained a .scp file and not as an attachment.

The template for multipart/alternative allows switching between the
alternatives.
2019-03-02 23:33:39 +01:00
Peter J. Holzer 090fd79c79 Add some more templates 2019-03-02 22:15:53 +01:00
Peter J. Holzer a737ce1760 Handle application/pgp 2019-03-02 12:24:56 +01:00
Peter J. Holzer 9f44375354 Save all attachments to separate files
For now we just save them unmodified and give them an extension that
will cause the web server to provide the correct content-type. This is
probably *not safe*: A user could send malicious html as an attachment
and the browser will interpret it when another user clicks on the link.
We might try to sanitize attachments (but you would normally expect an
attachment to be preserved) or to preserve the content-dispostion header
(but I don't think this is possible with just a static archive).
2019-03-02 12:10:01 +01:00
Peter J. Holzer 48ea68eaef Don't require <base> tag 2019-03-01 22:52:41 +01:00
Peter J. Holzer 7f5ffdde0b Handle <ol> and <u> tags 2019-03-01 22:52:07 +01:00