| 868 | } |
| 869 | |
| 870 | static int is_rfc2822_header(const struct strbuf *line) |
| 871 | { |
| 872 | /* |
| 873 | * The section that defines the loosest possible |
| 874 | * field name is "3.6.8 Optional fields". |
| 875 | * |
| 876 | * optional-field = field-name ":" unstructured CRLF |
| 877 | * field-name = 1*ftext |
| 878 | * ftext = %d33-57 / %59-126 |
| 879 | */ |
| 880 | int ch; |
| 881 | char *cp = line->buf; |
| 882 | |
| 883 | /* Count mbox From headers as headers */ |
| 884 | if (starts_with(cp, "From ") || starts_with(cp, ">From ")) |
| 885 | return 1; |
| 886 | |
| 887 | while ((ch = *cp++)) { |
| 888 | if (ch == ':') |
| 889 | return 1; |
| 890 | if ((33 <= ch && ch <= 57) || |
| 891 | (59 <= ch && ch <= 126)) |
| 892 | continue; |
| 893 | break; |
| 894 | } |
| 895 | return 0; |
| 896 | } |
| 897 | |
| 898 | static int read_one_header_line(struct strbuf *line, FILE *in) |
| 899 | { |
no test coverage detected