| 896 | } |
| 897 | |
| 898 | static int read_one_header_line(struct strbuf *line, FILE *in) |
| 899 | { |
| 900 | struct strbuf continuation = STRBUF_INIT; |
| 901 | |
| 902 | /* Get the first part of the line. */ |
| 903 | if (strbuf_getline_lf(line, in)) |
| 904 | return 0; |
| 905 | |
| 906 | /* |
| 907 | * Is it an empty line or not a valid rfc2822 header? |
| 908 | * If so, stop here, and return false ("not a header") |
| 909 | */ |
| 910 | strbuf_rtrim(line); |
| 911 | if (!line->len || !is_rfc2822_header(line)) { |
| 912 | /* Re-add the newline */ |
| 913 | strbuf_addch(line, '\n'); |
| 914 | return 0; |
| 915 | } |
| 916 | |
| 917 | /* |
| 918 | * Now we need to eat all the continuation lines.. |
| 919 | * Yuck, 2822 header "folding" |
| 920 | */ |
| 921 | for (;;) { |
| 922 | int peek; |
| 923 | |
| 924 | peek = fgetc(in); |
| 925 | if (peek == EOF) |
| 926 | break; |
| 927 | ungetc(peek, in); |
| 928 | if (peek != ' ' && peek != '\t') |
| 929 | break; |
| 930 | if (strbuf_getline_lf(&continuation, in)) |
| 931 | break; |
| 932 | continuation.buf[0] = ' '; |
| 933 | strbuf_rtrim(&continuation); |
| 934 | strbuf_addbuf(line, &continuation); |
| 935 | } |
| 936 | strbuf_release(&continuation); |
| 937 | |
| 938 | return 1; |
| 939 | } |
| 940 | |
| 941 | static int find_boundary(struct mailinfo *mi, struct strbuf *line) |
| 942 | { |
no test coverage detected