iz
Clone
https://git.tahinli.com/Tahinli/iz.git
0 watching0 forksRustAGPL-3.0567.3 KiB3950aceTahinli27 days ago34 commits
| 1 | //! Builds the message of one outbox row with lettre's typed builders. It is the only place a mail |
| 2 | //! header is written, and it never takes a header from text: every name and the subject go through |
| 3 | //! `clean_text` first, so a CR or LF in a member's name or an actor's name cannot start a header line. |
| 4 | //! |
| 5 | //! The body is plain text, and an HTML alternative is made from it here with every character escaped. |
| 6 | //! It is not a rendering of a page, so it never contains a link or script the text did not have. |
| 7 | |
| 8 | use clean_text; |
| 9 | use Sender; |
| 10 | use Address; |
| 11 | use ; |
| 12 | |
| 13 | /// Longest subject sent, in characters. Reason: the same cap as the subject field of a rule. |
| 14 | pub const SUBJECT_MAX: usize = MAIL_SUBJECT_MAX; |
| 15 | /// Longest display name of a mailbox, in characters. Reason: a name is a label, not a sentence. |
| 16 | const NAME_MAX: usize = 100; |
| 17 | /// Message-ID domain used when the base URL has no usable host. Reason: a fixed, valid fallback. |
| 18 | const FALLBACK_DOMAIN: &str = "localhost"; |
| 19 | |
| 20 | /// What the builder needs besides the row: the sender's configuration and the recipient. |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | /// Builds the message. `Err` holds the reason as text; the caller stores it as the last error. |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | /// The text with control and invisible formatting characters removed, cut to `max` characters. |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | /// `None` for an empty name, so the mailbox has only the address. |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | /// The body with CRLF and CR turned into LF, and control characters other than tab and LF removed. |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | /// The HTML alternative: each line is one paragraph, every character escaped. Nothing else is emitted. |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | /// Escapes the five characters that are special in HTML text and attribute values. |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | /// The host of a base URL, reduced to letters, digits, dots and dashes. The fallback when it is empty. |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | /// `domain` if it is made of letters, digits, dots and dashes; the fallback otherwise. |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 |