| 385 | } |
| 386 | |
| 387 | static int decode_q_segment(struct strbuf *out, const struct strbuf *q_seg, |
| 388 | int rfc2047) |
| 389 | { |
| 390 | const char *in = q_seg->buf; |
| 391 | int c; |
| 392 | strbuf_grow(out, q_seg->len); |
| 393 | |
| 394 | while ((c = *in++) != 0) { |
| 395 | if (c == '=') { |
| 396 | int ch, d = *in; |
| 397 | if (d == '\n' || !d) |
| 398 | break; /* drop trailing newline */ |
| 399 | ch = hex2chr(in); |
| 400 | if (ch >= 0) { |
| 401 | strbuf_addch(out, ch); |
| 402 | in += 2; |
| 403 | continue; |
| 404 | } |
| 405 | /* garbage -- fall through */ |
| 406 | } |
| 407 | if (rfc2047 && c == '_') /* rfc2047 4.2 (2) */ |
| 408 | c = 0x20; |
| 409 | strbuf_addch(out, c); |
| 410 | } |
| 411 | return 0; |
| 412 | } |
| 413 | |
| 414 | static int decode_b_segment(struct strbuf *out, const struct strbuf *b_seg) |
| 415 | { |
no test coverage detected