Re: folded x-header altered
Joshua Crawford <[email protected]>
| Newsgroups | gmane.network.tin.devel,gmane.network.tin.user |
|---|---|
| Message-ID | <[email protected]> |
Cc'ed to tin-dev. * Urs Janßen <[email protected]> [2003-10-21 00:57 +0200]: > > [ Original mail bounced due to non member submission ] Sorry about that. I'd just set up two new mail accounts (the old one having exceeded its monthly bandwidth allowance at the time because of Swen) - one for lists, the other for personal mail - but had forgotten to set mutt up to use the list one when appropriate. >> Using tin 1.7.1 here. I have an X-Face: in my ~/.tin/headers file >> and it has been working fine until I changed to a new face a few >> hours ago. With the new one, tin adds a space after a colon in the >> second line (the line starts with a space so tin should recognise >> it as folded, if it proceses the x_headers at all, yes?) > > in theory x_headers should be included as is, in practice this isn't > always possible (i.e. ppl. using unecoded 8bit chars in a subject set > via x_headers etc.pp.) - we might fail to defolde and refolde those > headers (if we touch them at all, I didn't check the code). The code breaks each line into header field and body, and passes them to msg_add_header(). It working with my old X-Face: was a sheer fluke. > as a > quick fix I'd say: don't use folded headers in x_headers if possible > (as long as there are no 8bit chars in them they must not be > mime-encoded and thus can be 998 octets long). I did this temporarily, as I said in the original message. Then totally forgot about it until today, when I wrote the attached patch. This patch also allows a script to be used for x_headers (like with sigfile). While I probably won't use it myself, I don't like seeing the X-Uptime: header some slrn users insert and knowing that it isn't possible with tin. -- Joshua 'bruce' Crawford ... http://www.geocities.com/mortarn Don't believe everything you hear or anything you say.
PATCH_tin-1.7.2-folded_xheaders+xheader_script-1
(text/plain, 3.8 KB)
diff -Nupr tin-1.7.2.orig/doc/tin.5 tin-1.7.2/doc/tin.5
--- tin-1.7.2.orig/doc/tin.5 2003-10-13 01:44:05.000000000 +1000
+++ tin-1.7.2/doc/tin.5 2003-11-09 20:39:57.000000000 +1100
@@ -507,8 +507,10 @@ Insert ''X-Comment-To:''-header, this is
.B x_headers
A string including header-name and the contents of the header that will
be automatically added when posting. If the string starts with a / or ~
-then it is assumed to be the name of a file containing the header and it's
-content to be inserted.
+then it is assumed to be the name of a file containing the header and its
+content to be inserted. If the string starts with a ! then what follows
+is assumed to be the path to a program to be executed to generate the
+header and its content.
.TP
.B quick_kill_scope
A comma-separated list of newsgroup patterns (wildmat-style) to which
diff -Nupr tin-1.7.2.orig/src/post.c tin-1.7.2/src/post.c
--- tin-1.7.2.orig/src/post.c 2003-10-16 11:04:11.000000000 +1000
+++ tin-1.7.2/src/post.c 2003-11-09 20:36:38.000000000 +1100
@@ -368,7 +368,7 @@ msg_add_header(
for (p = text; *p && (*p == ' ' || *p == '\t'); p++)
;
new_text = my_strdup(p);
- ptr = strchr(new_text, '\n');
+ ptr = strrchr(new_text, '\n');
if (ptr)
*ptr = '\0';
@@ -387,7 +387,7 @@ msg_add_header(
for (p = text; *p && (*p == ' ' || *p == '\t'); p++)
;
new_text = my_strdup(p);
- ptr = strchr(new_text, '\n');
+ ptr = strrchr(new_text, '\n');
if (ptr)
*ptr = '\0';
@@ -406,11 +406,16 @@ msg_write_headers(
{
int i;
int wrote = 1;
+ char *p;
for (i = 0; i < MAX_MSG_HEADERS; i++) {
if (msg_headers[i].name) {
fprintf(fp, "%s: %s\n", msg_headers[i].name, BlankIfNull(msg_headers[i].text));
- wrote++;
+ p = msg_headers[i].text;
+ do {
+ wrote++;
+ p = strchr(++p, '\n');
+ } while (p);
}
}
fputc('\n', fp);
@@ -3701,11 +3706,15 @@ msg_add_x_headers(
char *ptr;
char file[PATH_LEN];
char line[HEADER_LEN];
+ char **x_hdrs = NULL;
+ int num_x_hdrs = 0;
+ int pipe = 0;
+ int i;
if (!headers)
return;
- if (headers[0] != '/' && headers[0] != '~') {
+ if (headers[0] != '/' && headers[0] != '~' && headers[0] != '!') {
strcpy(line, headers);
ptr = strchr(line, ':');
if (ptr) {
@@ -3724,19 +3733,49 @@ msg_add_x_headers(
if (!strfpath(headers, file, sizeof(file), &CURR_GROUP))
strcpy(file, headers);
- if ((fp = fopen(file, "r")) != NULL) {
- while (fgets(line, (int) sizeof(line), fp) != NULL) {
- if (line[0] != '\n' && line[0] != '#') {
- ptr = strchr(line, ':');
- if (ptr) {
- *ptr = '\0';
- ptr++;
- }
- msg_add_header(line, ptr);
+#ifndef DONT_HAVE_PIPING
+ if (file[0] == '!')
+ if ((fp = popen(file + 1, "r")) == NULL)
+ return;
+ else
+ pipe = 1;
+#endif /* !DONT_HAVE_PIPING */
+ if (!pipe && ((fp = fopen(file, "r")) == NULL))
+ return;
+
+ while (fgets(line, (int) sizeof(line), fp) != NULL) {
+ if (line[0] != '\n' && line[0] != '#') {
+ if (line[0] != ' ' && line[0] != '\t') {
+ x_hdrs = my_realloc(x_hdrs, (num_x_hdrs + 1) * sizeof(char *));
+ x_hdrs[num_x_hdrs] = my_malloc(strlen(line) + 1);
+ strcpy(x_hdrs[num_x_hdrs++], line);
+ } else {
+ if (!num_x_hdrs)
+ /* folded line, but no previous header */
+ continue;
+ i = strlen(x_hdrs[num_x_hdrs - 1]);
+ x_hdrs[num_x_hdrs - 1] = my_realloc(x_hdrs[num_x_hdrs - 1], i + strlen(line) + 1);
+ strcpy(x_hdrs[num_x_hdrs - 1] + i, line);
}
}
- fclose(fp);
}
+ if (num_x_hdrs) {
+ for (i = 0; i < num_x_hdrs; i++) {
+ ptr = strchr(x_hdrs[i], ':');
+ if (ptr) {
+ *ptr = '\0';
+ ptr++;
+ }
+ msg_add_header(x_hdrs[i], ptr);
+ free(x_hdrs[i]);
+ }
+ free(x_hdrs);
+ }
+
+ if (pipe)
+ pclose(fp);
+ else
+ fclose(fp);
}
}
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/rhTmfNeFlNwRVjIRAmtiAKDqSh4uTkA0leFmvRz4VsFdZ5ByEgCeOvQe o36/o0VvWTP+fOkYjuqOaqc= =C64E -----END PGP SIGNATURE-----