tRemove whitespace characters from header values. - rohrpost - A commandline mail client to change the world as we see it.
 (HTM) git clone git://r-36.net/rohrpost
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit e564bee669d6957b144d2e36f7938ec3a9a43c75
 (DIR) parent 612b4635f36c5ad16c9c651416a3c85111dce99a
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Sun, 28 Oct 2018 18:30:41 +0100
       
       Remove whitespace characters from header values.
       
       Keeping for example newline in headers will break and is unexpected.
       
       Diffstat:
         ind.c                               |      12 ++++++++++++
         ind.h                               |       1 +
         mime.c                              |       3 +++
       
       3 files changed, 16 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/ind.c b/ind.c
       t@@ -500,6 +500,18 @@ strisascii(char *str)
                return 1;
        }
        
       +void
       +strnormalizespace(char *str)
       +{
       +        int len, i;
       +
       +        len = strlen(str);
       +        for (i = 0; i < len; i++) {
       +                if (isspace(str[i]))
       +                        str[i] = ' ';
       +        }
       +}
       +
        /*
         * Find a whitespace character in a certain limit. This is used for formatting
         * mail to a certain width.
 (DIR) diff --git a/ind.h b/ind.h
       t@@ -46,6 +46,7 @@ char *strcsh(char *p, char *chars);
        char *strncsh(char *p, char *chars);
        char *strrlnspn(char *p, char *chars, int limit);
        int strisascii(char *str);
       +void strnormalizespace(char *str);
        char *findlimitws(char *str, int limit);
        
        char *mktmpfile(char *prefix, char *suffix, int *fd);
 (DIR) diff --git a/mime.c b/mime.c
       t@@ -307,6 +307,9 @@ mime_decodeheader(char *value)
                        ret = memdupcat(ret, rlen, extp, strlen(extp)+1);
                free(work);
        
       +        /* Remove any space character, like newline. */
       +        strnormalizespace(ret);
       +
                return ret;
        }