URI:
       sfeed_mbox: set the author as the display name for the From header again - sfeed - RSS and Atom parser
  HTML git clone git://git.codemadness.org/sfeed
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit e2537f08dde958c02f835229ae11c5db785abd2a
   DIR parent a16377b91f996a3cc9772c23cc8aadd48a13651c
  HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Fri, 26 Dec 2025 21:03:27 +0100
       
       sfeed_mbox: set the author as the display name for the From header again
       
       SFEED_MBOX_FROM now always overrides the header if it is set.
       Otherwise the default e-mail is <anonymous@localhost>, if there is an author
       name it is displayed.
       
       The name is quoted. For simplicity some characters like quotes, escape
       characters or text-encoding characters are removed, they are not handled at all
       (note that the author field cannot contain escape characters already, unless
       the user modified the parsed sfeed(5) format).
       
       Diffstat:
         M sfeed_mbox.1                        |      12 +++++++-----
         M sfeed_mbox.c                        |      28 ++++++++++++++++++++++++++--
       
       2 files changed, 33 insertions(+), 7 deletions(-)
       ---
   DIR diff --git a/sfeed_mbox.1 b/sfeed_mbox.1
       @@ -1,4 +1,4 @@
       -.Dd October 10, 2025
       +.Dd December 26, 2025
        .Dt SFEED_MBOX 1
        .Os
        .Sh NAME
       @@ -54,11 +54,13 @@ This can be insecure for some of the mail clients that interpret HTML code in
        an unsafe way.
        By default this is set to "0".
        .It Ev SFEED_MBOX_FROM
       -Override the host for the "From" header.
       -The default is "anonymous@localhost".
       +Override the "From" header.
       +The default is the author of the item (if it has one) and
       +the e-mail "<anonymous@localhost>".
       +Some unsafe characters are removed from the author field.
        .It Ev SFEED_MBOX_TO
       -Override the user for the "To" header.
       -The default is "anonymous@localhost".
       +Override the "To" header.
       +The default is "<anonymous@localhost>".
        .El
        .Sh EXIT STATUS
        .Ex -std
   DIR diff --git a/sfeed_mbox.c b/sfeed_mbox.c
       @@ -10,7 +10,7 @@ static size_t linesize;
        static char dtimebuf[32], mtimebuf[32];
        
        /* env variables: $SFEED_MBOX_FROM and $SFEED_MBOX_TO */
       -static char *from = "<anonymous@localhost>", *to = "<anonymous@localhost>";
       +static char *from = NULL, *to = "<anonymous@localhost>";
        /* env variable: $SFEED_MBOX_CONTENT */
        static int usecontent = 0;
        
       @@ -24,6 +24,21 @@ djb2(unsigned char *s, unsigned long long hash)
                return hash;
        }
        
       +/* Print the author field, do not allow quoted characters or text encoding. */
       +static void
       +printauthor(const char *s)
       +{
       +        for (; *s; s++) {
       +                if (*s == '\\' || *s == '?' || *s == '=')
       +                        continue;
       +                if (*s == '"')
       +                        putchar('\'');
       +                else
       +                        putchar(*s);
       +        }
       +}
       +
       +/* Print the category field, replace the '|' separator by a comma (','). */
        static void
        printtags(const char *s)
        {
       @@ -98,7 +113,16 @@ printfeed(FILE *fp, const char *feedname)
                                printf("Date: %s\n", dtimebuf); /* invalid/missing: use current time */
                        }
        
       -                printf("From: %s\n", from);
       +                if (from) {
       +                        printf("From: %s\n", from);
       +                } else if (fields[FieldAuthor][0]) {
       +                        fputs("From: \"", stdout);
       +                        printauthor(fields[FieldAuthor]);
       +                        fputs("\" <anonymous@localhost>\n", stdout);
       +                } else {
       +                        fputs("From: <anonymous@localhost>\n", stdout);
       +                }
       +
                        printf("To: %s\n", to);
                        printf("Subject: %s\n", fields[FieldTitle]);
                        printf("Message-ID: <%s%s%llu@newsfeed.local>\n",