| 291 | /* mime_state_downgrade - convert 8-bit data to quoted-printable */ |
| 292 | |
| 293 | void mime_state_downgrade(MIME_STATE *state, int rec_type, |
| 294 | const char *text, ssize_t len) |
| 295 | { |
| 296 | static char hexchars[] = "0123456789ABCDEF"; |
| 297 | const unsigned char *cp; |
| 298 | MIME_NODE *node = state->curr_node; |
| 299 | int ch; |
| 300 | |
| 301 | #define CU_CHAR_PTR(x) ((const unsigned char *) (x)) |
| 302 | #define QP_ENCODE(buffer, ch) { \ |
| 303 | buffer += '='; \ |
| 304 | buffer += (char) hexchars[(ch >> 4) & 0xff]; \ |
| 305 | buffer += (char) hexchars[ch & 0xf]; \ |
| 306 | } |
| 307 | |
| 308 | /* |
| 309 | * Insert a soft line break when the output reaches a critical length |
| 310 | * before we reach a hard line break. |
| 311 | */ |
| 312 | for (cp = CU_CHAR_PTR(text); cp < CU_CHAR_PTR(text + len); cp++) { |
| 313 | /* Critical length before hard line break. */ |
| 314 | if (LEN(node->buffer) > 72) { |
| 315 | node->buffer += '='; |
| 316 | } |
| 317 | /* Append the next character. */ |
| 318 | ch = *cp; |
| 319 | if ((ch < 32 && ch != '\t') || ch == '=' || ch > 126) { |
| 320 | QP_ENCODE(node->buffer, ch); |
| 321 | } else { |
| 322 | ADDCH(node->buffer, ch); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | /* |
| 327 | * Flush output after a hard line break (i.e. the end of a REC_TYPE_NORM |
| 328 | * record). Fix trailing whitespace as per the RFC: in the worst case, |
| 329 | * the output length will grow from 73 characters to 75 characters. |
| 330 | */ |
| 331 | if (rec_type == REC_TYPE_NORM) { |
| 332 | if (LEN(node->buffer) > 0 |
| 333 | && ((ch = END(node->buffer)[-1]) == ' ' || ch == '\t')) |
| 334 | { |
| 335 | acl_vstring_truncate(node->buffer, LEN(node->buffer) - 1); |
| 336 | QP_ENCODE(node->buffer, ch); |
| 337 | } |
| 338 | ACL_VSTRING_TERMINATE(node->buffer); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | static ACL_FIFO *mail_addr_add(ACL_FIFO *addr_list, const char *addr) |
| 343 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…