[PATCH] cooked headers did rfc2047-decode everything which looked like an encoded word
Urs Janßen <[email protected]> Wed, 18 Mar 2009 09:49:59 +0100
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
the untested patch below fixes the article display.
tin still wrongly encodes some headers (i.e. if a Message-ID looks like an
encoded word tin will encode it once again to keep it's original format
instead of skipping References and the like when encoding an article) -> we
have todo something like this in rfc2047.c:rfc1522_do_encode().
=== modified file 'src/cook.c'
--- src/cook.c 2009-02-25 08:12:30 +0000
+++ src/cook.c 2009-03-18 08:44:25 +0000
@@ -802,8 +802,84 @@
}
if (header_wanted(line)) { /* Put cooked data */
+ char *l, *ptr;
size_t i = LEN;
- char *l = my_strdup(rfc1522_decode(line)); /* FIXME: don't decode addr-part of From:/Cc:/ etc.pp. */
+ t_bool found = FALSE;
+
+ /* unstructured but must not be decoded */
+ if (!strncasecmp(line, "References: ", 12) || !strncasecmp(line, "Message-ID: ", 12) || !strncasecmp(line, "Date: ", 6) || !strncasecmp(line, "Newsgroups: ", 12) || !strncasecmp(line, "Distribution: ", 14) || !strncasecmp(line, "Followup-To: ", 13) || !strncasecmp(line, "X-Face: ", 8)) {
+ l = my_strdup(line);
+ found = TRUE;
+ }
+ /* TODO: join this "list" with the one in rfc1522_do_encode() */
+ if (!found && (ptr = parse_header(line, "From", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 6 + 1); /* "From: " */
+ strncpy(l, line, 6);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "To", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 4 + 1); /* "To: " */
+ strncpy(l, line, 4);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "Cc", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 4 + 1); /* "Cc: " */
+ strncpy(l, line, 4);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "Bcc", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 5 + 1); /* "Bcc: " */
+ strncpy(l, line, 5);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "Reply-To", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 10 + 1); /* "Reply-To: " */
+ strncpy(l, line, 10);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "Approved", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 10 + 1); /* "Approved: " */
+ strncpy(l, line, 10);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "Originator", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 12 + 1); /* "Originator: " */
+ strncpy(l, line, 12);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "X-Comment-To", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 14 + 1); /* "X-Comment-To: " */
+ strncpy(l, line, 14);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "X-Cancelled-By", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 16 + 1); /* "X-Cancelled-By: " */
+ strncpy(l, line, 16);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "X-Submissions-To", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 18 + 1); /* "X-Submissions-To: " */
+ strncpy(l, line, 18);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found && (ptr = parse_header(line, "X-Originator", TRUE, TRUE))) {
+ l = my_malloc(strlen(ptr) + 14 + 1); /* "X-Originator: " */
+ strncpy(l, line, 14);
+ strcat(l, ptr);
+ found = TRUE;
+ }
+ if (!found)
+ l = my_strdup(rfc1522_decode(line));
#if defined(MULTIBYTE_ABLE) && !defined(NO_LOCALE)
if (IS_LOCAL_CHARSET("UTF-8"))