Commit Graph

50 Commits (master)

Author SHA1 Message Date
Leah Neukirchen cf5493bb19 mmime: don't create empty lines when wrapping long words in headers.
Reported by Solène Rapenne.
2 months ago
Michael Forney 74e77845c3 mmime: include strings.h for strncasecmp 1 year ago
Lucas e951b0ba27 mmime: allow to relax body line length limit
Message-Id: <10e22a318b5c70d89432d85ecd8cb8ce1796a51d.1643116719.git.lucas@sexy.is>
2 years ago
Leah Neukirchen 4ccf2f08c1 mmime: ensure no empty parts are generated after an include.
Reported by lhynes.
3 years ago
Leah Neukirchen d324b92dd4 mmime: keep (none) whitespace after quoted strings 3 years ago
Leah Neukirchen 0370916357 mmime: generate valid empty mime multipart/mixed when no body is given 3 years ago
Leah Neukirchen 4e0de11300 mmime: print_header: encode quoted-strings at once
This is maybe a foul compromise between correctness and complexity of
implementation, but it should do the right thing in most cases, and
does not require fully parsing and reconstructing all headers that can
contain phrases.

An 'encoded-word' MUST NOT appear within a 'quoted-string'.  We thus
completely encode the quoted-string (if necessary) as a single
encoded-word, and strip off the quotes.

This should fix encoding of addresses that have both non-ASCII and
special chars such as , and ;.
3 years ago
Leah Neukirchen 9713264f70 mmime: be more careful when qp-encoding in headers
Characters such as , or ; mustn't appear in qp-encoded strings,
as they have a meaning in phrases.  To be safe, encode all special
characters except for the safe ones in RFC 2047 5.(3).

_ is dealt with already.
3 years ago
Leah Neukirchen 5b52110399 mmime: do not duplicate Content* headers
Do not add additional Content-Type and Content-Transfer-Encoding headers
when using mmime on input already containing them.

Do not reencode the message if Content-Transfer-Encoding is set.

Based on a patch by Felix Van der Jeugt and duncaen.
3 years ago
Leah Neukirchen c525c0097e mmime: allow # in include lines, used to override the content-disposition 3 years ago
Leah Neukirchen 48c20b7efa mmime: propagate errors when attaching a file fails 4 years ago
Tim Kuijsten 4763032430 pledge(2) all programs
All programs except mshow have a very tight set of promises. mshow
has a broad set of promises and might be a good future candidate
to further restrict using unveil(2).

This patch is based on commit 0300a112 by Alex Holst (dated
2017-12-07), which was proposed in GH PR #79.

* pledged mpick, mflow and mdate so that now all programs are pledged
* removed some unneeded promises and added some missing promises
* move err.h include and OpenBSD ifdef into a new xpledge.h
* cleaned up code aligning and whitespace

Closes: #179 [via git-merge-pr]
4 years ago
Leah Neukirchen 6bd687bfdc mmime: allow ; and =, for ";charset=" 4 years ago
Leah Neukirchen fec4e06671 mmime: be more strict when detecting content types for the include syntax
Previously, shebangs would be (mis)detected: #!/bin/sh -e
4 years ago
Leah Neukirchen 5fa9a7a706 mmime: gen_file: remove check for trailing newline for 7bit transfer
RFC2046 5.1.1 specifies that parts without trailing newlines are coded
without problems:

> NOTE:  The CRLF preceding the boundary delimiter line is conceptually
> attached to the boundary so that it is possible to have a part that
> does not end with a CRLF (line break).

This if-statement now also codes empty files correctly.
5 years ago
Leah Neukirchen 3a97df9990 mmime: print_header: fix for empty lines 5 years ago
Leah Neukirchen 237ad8a2f3 mmime: print_header: use signed variable for linelen 5 years ago
Leah Neukirchen 5f45b7d533 use appropriate integer types
Mainly found with clang -Wconversion -Wshorten-64-to-32.
7 years ago
Leah Neukirchen d4cbac0aa5 mmime: gen_qp: quote ^From and ^.$ to be safe 7 years ago
Leah Neukirchen 54435b30b6 mmime: gen_qp: encode trailing space and tab as =20/=09
See RFC2045 6.7.(3):
> It follows that an octet with decimal value 9 or 32 appearing at the
> end of an encoded line must be represented according to Rule #1.

Prefer this over generating a soft-line break and then a real line break.
7 years ago
Leah Neukirchen 66d0eff12f style 7 years ago
Leah Neukirchen 4a685de739 mmime: ensure 7bit or 8bit Content-Transfer-Encoding for message/rfc822 parts
RFC 2046, Section 5.2.1:
> No encoding other than "7bit", "8bit", or "binary" is permitted for
> the body of a "message/rfc822" entity.

(We'll generate 8bit when we have to and put the blame on the MTA.)
7 years ago
Leah Neukirchen 958ad4e9f6 mmime: disregard line length restriction for message/rfc822 attachments
Many webmail client's don't like qp-encoded message/rfc822 attachments.
7 years ago
Leah Neukirchen 613a1182ff mmime: gen_qp: ensure not to split utf8 multibyte sequences into encoded words
RFC2047, 5.(3):
> Each 'encoded-word' MUST represent an integral number of characters.
> A multi-octet character may not be split across adjacent 'encoded-
> word's.
7 years ago
Leah Neukirchen fc4e4af774 mmime: don't generate empty filenames 7 years ago
Leah Neukirchen cc7ab25814 mmime: allow setting content-disposition and overriding filename 7 years ago
Leah Neukirchen 938b2c2d31 mmime: gen_attachment: try to generate filenames as atoms, use qp for double quotes 7 years ago
Leah Neukirchen 46a44e2f22 mmime: add mblaze/raw for plain text inclusion 7 years ago
Leah Neukirchen d8976d416c mmime: add -t to override toplevel content-type 7 years ago
Leah Neukirchen 67c0a3b17c mmime: print_header: only force qp-encoding for overlong lines
Lines SHOULD not be longer than 78 chars, and we try to fold like that,
but we only enforce qp-encoding for 7-bit safe lines if they would be
longer than 998, which they MUST not be.
7 years ago
Leah Neukirchen f53e8dc672 mmime: check: allow up to 998 chars in header lines 7 years ago
Leah Neukirchen d75c446aff mmime: use RFC2231 for Content-Disposition when needed 7 years ago
Leah Neukirchen d73a3a748a mmime: gen_file: append newline to error message 7 years ago
Leah Neukirchen 2d612ce166 mmime: print_header: refactor
Simplifies the code considerably.  QP-header-wrapping now happens inside
gen_qp.  We wrap the line in advance when this will save QP-encoding, or
splitting a QP-word into two.

Fixes #20.
7 years ago
Leah Neukirchen 2b4e3aa66d clean up whitespace 7 years ago
Christian Neukirchen 2ef903a065 mmime: don't truncate a #type line when it has invalid syntax 8 years ago
Christian Neukirchen 3095d48655 mmime: ensure a new token in qp header generation 8 years ago
Christian Neukirchen f56755cffd mman: gen_file: slurp the file instead of mmap 8 years ago
Christian Neukirchen 0b2e4880f5 mmime: gen_build: don't crash on #-line without space 8 years ago
Christian Neukirchen 472a74b75b use getdelim instead of getline
Avoids weird macros to build on FreeBSD.
8 years ago
Christian Neukirchen f9226dde7b mmime: generate LF before MIME boundaries 8 years ago
Christian Neukirchen d138866fd6 mmime: line length must be <=78 8 years ago
Christian Neukirchen c4822a983b mmime: add -c to check if MIME-encoding is needed 8 years ago
Christian Neukirchen 2073102d4d mmime: add -r for plain text 8 years ago
Christian Neukirchen a52af29aa9 mmime: simplify 8 years ago
Christian Neukirchen cf594afb83 mmime: fix prevq logic 8 years ago
Christian Neukirchen 0ce958a22c mmime: only qp after newline when actually needed 8 years ago
Christian Neukirchen c6d4c79771 mmime: delete dead store
Found by clang-analyzer.
8 years ago
Christian Neukirchen b8c2685a60 mmime: encode headers when neccessary
This is still a bit clumsy, but I'm not sure how to make it better.
8 years ago
Christian Neukirchen 9545981777 add mmime 8 years ago