* the () pair at the end.
*/
strbuf_trim(&f);
- if (f.buf[0] == '(')
- strbuf_remove(&name, 0, 1);
- if (f.len && f.buf[f.len - 1] == ')')
+ if (f.buf[0] == '(' && f.len && f.buf[f.len - 1] == ')') {
+ strbuf_remove(&f, 0, 1);
strbuf_setlen(&f, f.len - 1);
+ }
get_sane_name(&name, &f, &email);
strbuf_release(&f);
static int is_multipart_boundary(const struct strbuf *line)
{
- return !strbuf_cmp(line, *content_top);
+ return (((*content_top)->len <= line->len) &&
+ !memcmp(line->buf, (*content_top)->buf, (*content_top)->len));
}
static void cleanup_subject(struct strbuf *subject)
check_header(&line, p_hdr_data, 0);
strbuf_release(&newline);
- /* eat the blank line after section info */
- return (strbuf_getline(&line, fin, '\n') == 0);
+ /* replenish line */
+ if (strbuf_getline(&line, fin, '\n'))
+ return 0;
+ strbuf_addch(&line, '\n');
+ return 1;
}
static inline int patchbreak(const struct strbuf *line)
/* process any boundary lines */
if (*content_top && is_multipart_boundary(&line)) {
/* flush any leftover */
- if (line.len)
- handle_filter(&line);
-
+ if (prev.len) {
+ handle_filter(&prev);
+ strbuf_reset(&prev);
+ }
if (!handle_boundary())
goto handle_body_out;
}