maddy

Fork https://github.com/foxcpp/maddy

git clone git://git.lin.moe/go/maddy.git

 1# Unicode support
 2
 3maddy has the first-class Unicode support in all components (modules). You do
 4not have to take any actions to make it work with internationalized domains,
 5mailbox names or non-ASCII message headers.
 6
 7Internally, all text fields in maddy are represented in UTF-8 and handled using
 8Unicode-aware operations for comparisons, case-folding and so on.
 9
10## Non-ASCII data in message headers and bodies
11
12maddy SMTP implementation does not care about encodings used in MIME headers or
13in `Content-Type text/*` charset field.
14
15However, local IMAP storage implementation needs to perform certain operations
16on header contents. This is mostly about SEARCH functionality. For IMAP search
17to work correctly, the message body and headers should use one of the following
18encodings:
19
20- ASCII
21- UTF-8
22- ISO-8859-1, 2, 3, 4, 9, 10, 13, 14, 15 or 16
23- Windows-1250, 1251 or 1252 (aka Code Page 1250 and so on)
24- KOI8-R
25- ~~HZGB2312~~, GB18030
26- GBK (aka Code Page 936)
27- Shift JIS (aka Code Page 932 or Windows-31J)
28- Big-5 (aka Code Page 950)
29- EUC-JP
30- ISO-2022-JP
31
32_Support for HZGB2312 is currently disabled due to bugs with security
33implications._
34
35If mailbox includes a message with any encoding not listed here, it will not
36be returned in search results for any request.
37
38Behavior regarding handling of non-Unicode encodings is not considered stable
39and may change between versions (including removal of supported encodings). If
40you need your stuff to work correctly - start using UTF-8.
41
42## Configuration files
43
44maddy configuration files are assumed to be encoded in UTF-8. Use of any other
45encoding will break stuff, do not do it.
46
47Domain names (e.g. in hostname directive or pipeline rules) can be represented
48using the ACE form (aka Punycode). They will be converted to the Unicode form
49internally.
50
51## Local credentials
52
53'sql' storage backend and authentication provider enforce a number of additional
54constraints on used account names.
55
56PRECIS UsernameCaseMapped profile is enforced for local email addresses.
57It limits the use of control and Bidi characters to make sure the used value
58can be represented consistently in a variety of contexts. On top of that, the
59address is case-folded and normalized to the NFC form for consistent internal
60handling.
61
62PRECIS OpaqueString profile is enforced for passwords. Less strict rules are
63applied here. Runs of Unicode whitespace characters are replaced with a single
64ASCII space. NFC normalization is applied afterwards. If the resulting string
65is empty - the password is not accepted.
66
67Both profiles are defined in RFC 8265, consult it for details.
68
69## Protocol support
70
71### SMTPUTF8 extension
72
73maddy SMTP implementation includes support for the SMTPUTF8 extension as
74defined in RFC 6531.
75
76This means maddy can handle internationalized mailbox and domain names in MAIL
77FROM, RCPT TO commands both for outbound and inbound delivery.
78
79maddy will not accept messages with non-ASCII envelope addresses unless
80SMTPUTF8 support is requested. If a message with SMTPUTF8 flag set is forwarded
81to a server without SMTPUTF8 support, delivery will fail unless it is possible
82to represent envelope addresses in the ASCII form (only domains use Unicode and
83they can be converted to Punycode). Contents of message body (and header) are
84not considered and always accepted and sent as-is, no automatic downgrading or
85reencoding is done.
86
87### IMAP UTF8, I18NLEVEL extensions
88
89Currently, maddy does not include support for UTF8 and I18NLEVEL IMAP
90extensions. However, it is not a problem that can prevent it from correctly
91handling UTF-8 messages (or even messages in other non-ASCII encodings
92mentioned above).
93
94Clients that want to implement proper handling for Unicode strings may assume
95maddy does not handle them properly in e.g. SEARCH commands and so such clients
96may download messages and process them locally.