news_headers_to_display and folded headers
Dennis Preiser <[email protected]> Tue, 18 Jan 2011 18:23:09 +0100
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
Headers in news_headers_to_display are not properly unfolded. Beside headers like Subject:, which are displayed 'as is', some headers are altered. For example, the following From:-header: From: Dennis Preiser <[email protected]> is displayed as: From: Dennis Preiser? <[email protected]> '\n' is replaced by '?'. The same happens with Reply-To:. Attached patch adds unfold_header_to_display() to cook.c which does the unfolding for news_headers_to_display. At this point we cannot use rfc2046.c:unfold_header() because the leading '\t' of subsequent folded lines is not replaced with ' ' there. With this patch all headers in news_headers_to_display gets unfolded. I'm not shure whether this is necessary or not. Dennis --- tin-1.9.6_r3/src/cook.c 2011-01-17 21:28:56.000000000 +0100 +++ tin-1.9.6_r4/src/cook.c 2011-01-18 17:43:08.000000000 +0100 @@ -60,6 +60,7 @@ static t_bool header_wanted(const char * static t_part *new_uue(t_part **part, char *name); static void process_text_body_part(t_bool wrap_lines, FILE *in, t_part *part, int hide_uue); static void put_cooked(size_t buf_len, t_bool wrap_lines, int flags, const char *fmt, ...); +static void unfold_header_to_display(char *line); #if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE) static t_bool wexpand_ctrl_chars(wchar_t **wline, size_t *length, size_t lcook_width); #endif /* MULTIBYTE_ABLE && !NO_LOCALE */ @@ -778,6 +779,26 @@ charset_unsupported( } +static void +unfold_header_to_display( + char *line) +{ + char *src = line, *dst = line; + + while (*src) { + if (*src == '\n' && *(src + 1) && *(src + 1) == '\t') { + *dst++ = ' '; + src += 2; + } else if (*src == '\n') { + ++src; + } else { + *dst++ = *src++; + } + } + *dst = '\0'; +} + + /* * 'cooks' an article, ie, prepare what will actually appear on the screen * It is not easy to do this in the same pass as the initial read since @@ -850,7 +871,7 @@ cook_article( size_t i = LEN; t_bool found = FALSE; + unfold_header_to_display(line); /* structured headers */ do { if (!strncasecmp(line, *strptr, strlen(*strptr))) {