| 948 | } |
| 949 | |
| 950 | static int handle_boundary(struct mailinfo *mi, struct strbuf *line) |
| 951 | { |
| 952 | struct strbuf newline = STRBUF_INIT; |
| 953 | |
| 954 | strbuf_addch(&newline, '\n'); |
| 955 | again: |
| 956 | if (line->len >= (*(mi->content_top))->len + 2 && |
| 957 | !memcmp(line->buf + (*(mi->content_top))->len, "--", 2)) { |
| 958 | /* we hit an end boundary */ |
| 959 | /* pop the current boundary off the stack */ |
| 960 | strbuf_release(*(mi->content_top)); |
| 961 | FREE_AND_NULL(*(mi->content_top)); |
| 962 | |
| 963 | /* technically won't happen as is_multipart_boundary() |
| 964 | will fail first. But just in case.. |
| 965 | */ |
| 966 | if (--mi->content_top < mi->content) { |
| 967 | error("Detected mismatched boundaries, can't recover"); |
| 968 | mi->input_error = -1; |
| 969 | mi->content_top = mi->content; |
| 970 | strbuf_release(&newline); |
| 971 | return 0; |
| 972 | } |
| 973 | handle_filter(mi, &newline); |
| 974 | strbuf_release(&newline); |
| 975 | if (mi->input_error) |
| 976 | return 0; |
| 977 | |
| 978 | /* skip to the next boundary */ |
| 979 | if (!find_boundary(mi, line)) |
| 980 | return 0; |
| 981 | goto again; |
| 982 | } |
| 983 | |
| 984 | /* set some defaults */ |
| 985 | mi->transfer_encoding = TE_DONTCARE; |
| 986 | strbuf_reset(&mi->charset); |
| 987 | |
| 988 | /* slurp in this section's info */ |
| 989 | while (read_one_header_line(line, mi->input)) |
| 990 | check_header(mi, line, mi->p_hdr_data, 0); |
| 991 | |
| 992 | strbuf_release(&newline); |
| 993 | /* replenish line */ |
| 994 | if (strbuf_getline_lf(line, mi->input)) |
| 995 | return 0; |
| 996 | strbuf_addch(line, '\n'); |
| 997 | return 1; |
| 998 | } |
| 999 | |
| 1000 | static void handle_filter_flowed(struct mailinfo *mi, struct strbuf *line, |
| 1001 | struct strbuf *prev) |
no test coverage detected