| 1155 | } |
| 1156 | |
| 1157 | static void handle_info(struct mailinfo *mi) |
| 1158 | { |
| 1159 | struct strbuf *hdr; |
| 1160 | int i; |
| 1161 | |
| 1162 | for (i = 0; i < ARRAY_SIZE(header); i++) { |
| 1163 | /* only print inbody headers if we output a patch file */ |
| 1164 | if (mi->patch_lines && mi->s_hdr_data[i]) |
| 1165 | hdr = mi->s_hdr_data[i]; |
| 1166 | else if (mi->p_hdr_data[i]) |
| 1167 | hdr = mi->p_hdr_data[i]; |
| 1168 | else |
| 1169 | continue; |
| 1170 | |
| 1171 | if (memchr(hdr->buf, '\0', hdr->len)) { |
| 1172 | error("a NUL byte in '%s' is not allowed.", header[i]); |
| 1173 | mi->input_error = -1; |
| 1174 | } |
| 1175 | |
| 1176 | if (!strcmp(header[i], "Subject")) { |
| 1177 | if (!mi->keep_subject) { |
| 1178 | cleanup_subject(mi, hdr); |
| 1179 | cleanup_space(hdr); |
| 1180 | } |
| 1181 | output_header_lines(mi->output, "Subject", hdr); |
| 1182 | } else if (!strcmp(header[i], "From")) { |
| 1183 | cleanup_space(hdr); |
| 1184 | handle_from(mi, hdr); |
| 1185 | fprintf(mi->output, "Author: %s\n", mi->name.buf); |
| 1186 | fprintf(mi->output, "Email: %s\n", mi->email.buf); |
| 1187 | } else { |
| 1188 | cleanup_space(hdr); |
| 1189 | fprintf(mi->output, "%s: %s\n", header[i], hdr->buf); |
| 1190 | } |
| 1191 | } |
| 1192 | fprintf(mi->output, "\n"); |
| 1193 | } |
| 1194 | |
| 1195 | int mailinfo(struct mailinfo *mi, const char *msg, const char *patch) |
| 1196 | { |
no test coverage detected