summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2018-08-23 14:15:24 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2018-08-23 14:15:24 +0200
commit750ea4da07d585a299d1990b717f94507df1b8cd (patch)
tree0b21b03b75b5f20d46660373e6c58a1ac6f6c94a
parent663b4a4e04b5cd4d54704c2feedac4ded122abc1 (diff)
sfeed_mbox: improvements
- don't output content and HTML mail anymore: this is very insecure for most mail clients. - improve Content-Type utf-8 encoding header (use the more common form). - improve line-endings at the end of the data.
-rw-r--r--sfeed_mbox.14
-rw-r--r--sfeed_mbox.c56
2 files changed, 2 insertions, 58 deletions
diff --git a/sfeed_mbox.1 b/sfeed_mbox.1
index 027aa0c..c16c11e 100644
--- a/sfeed_mbox.1
+++ b/sfeed_mbox.1
@@ -23,16 +23,12 @@ If no
.Ar file
parameters are specified and so the data is read from stdin the feed name
is empty.
-Lines starting with "From " will be mangled in the mboxrd-style.
The mbox data can be further processed by tools like
.Xr procmail 1
or
.Xr fdm 1
for example.
See the README file for some useful examples.
-.Sh FORMAT
-Depending on the original content\-type the mail will be formatted as
-plain-text (text/plain) or HTML (text/html).
.Sh CUSTOM HEADERS
To make further filtering simpler some custom headers are set:
.Bl -tag -width Ds
diff --git a/sfeed_mbox.c b/sfeed_mbox.c
index fa1336d..7989d8e 100644
--- a/sfeed_mbox.c
+++ b/sfeed_mbox.c
@@ -70,47 +70,6 @@ murmur3_32(const char *key, uint32_t len, uint32_t seed)
return hash;
}
-/* Unescape / decode fields printed by string_print_encoded()
- * "\\" to "\", "\t", to TAB, "\n" to newline. Unrecognised escape sequences
- * are ignored: "\z" etc. Mangle "From " in mboxrd style (always prefix >). */
-static void
-printcontent(const char *s, FILE *fp)
-{
- if (!strncmp(s, "From ", 5))
- fputc('>', fp);
-
-read:
- for (; *s; s++) {
- switch (*s) {
- case '\\':
- switch (*(++s)) {
- case '\0': return; /* ignore */
- case '\\': fputc('\\', fp); break;
- case 't': fputc('\t', fp); break;
- case 'n':
- fputc('\n', fp);
- for (s++; *s == '>'; s++)
- fputc('>', fp);
- /* escape "From ", mboxrd-style. */
- if (!strncmp(s, "From ", 5))
- fputc('>', fp);
- goto read;
- }
- break;
- case '\n':
- fputc((int)*s, fp);
- for (s++; *s == '>'; s++)
- fputc('>', fp);
- /* escape "From ", mboxrd-style. */
- if (!strncmp(s, "From ", 5))
- fputc('>', fp);
- goto read;
- default:
- fputc((int)*s, fp);
- }
- }
-}
-
static void
printfeed(FILE *fp, const char *feedname)
{
@@ -148,22 +107,11 @@ printfeed(FILE *fp, const char *feedname)
fields[FieldUnixTimestamp][0] ? "." : "",
murmur3_32(line, (size_t)linelen, seed),
feedname);
- printf("Content-Type: text/%s; charset=UTF-8\n", fields[FieldContentType]);
+ printf("Content-Type: text/plain; charset=\"utf-8\"\n");
printf("Content-Transfer-Encoding: binary\n");
printf("X-Feedname: %s\n\n", feedname);
- if (!strcmp(fields[FieldContentType], "html")) {
- fputs("<p>Link: <a href=\"", stdout);
- xmlencode(fields[FieldLink], stdout);
- fputs("\">", stdout);
- fputs(fields[FieldLink], stdout);
- fputs("</a></p>\n\n", stdout);
- printcontent(fields[FieldContent], stdout);
- } else {
- printf("Link: %s\n\n", fields[FieldLink]);
- printcontent(fields[FieldContent], stdout);
- }
- fputs("\n\n", stdout);
+ printf("%s\n\n", fields[FieldLink]);
}
}