diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-11-10 16:13:54 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-11-19 19:25:03 +0100 |
commit | 881e43a03c774bf8d31b5fe751bd493447174ad0 (patch) | |
tree | fe073f91c6319a176733cd711674dc8ed66452b5 /win32 | |
parent | c2b1182879bf2785245638945851c241b0859cbb (diff) | |
download | php-git-881e43a03c774bf8d31b5fe751bd493447174ad0.tar.gz |
Fix #72964: White space not unfolded for CC/Bcc headers
`\r\n` does only terminate a header, if not followed by `\t` or ` `.
We have to cater to that when determining the end position of the
respective headers.
Closes GH-6420.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/sendmail.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/win32/sendmail.c b/win32/sendmail.c index 9e31028d58..c82dc7b3c6 100644 --- a/win32/sendmail.c +++ b/win32/sendmail.c @@ -458,6 +458,16 @@ static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char if (NULL == (pos2 = strstr(pos1, "\r\n"))) { tempMailTo = estrndup(pos1, strlen(pos1)); } else { + char *pos3; + while (pos2[2] == ' ' || pos2[2] == '\t') { + pos3 = strstr(pos2 + 2, "\r\n"); + if (pos3 != NULL) { + pos2 = pos3; + } else { + pos2 += strlen(pos2); + break; + } + } tempMailTo = estrndup(pos1, pos2 - pos1); } @@ -516,7 +526,22 @@ static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char header we know it was the last thing. */ pos2 = pos1; } else { + char *pos3 = NULL; + while (pos2[2] == ' ' || pos2[2] == '\t') { + pos3 = strstr(pos2 + 2, "\r\n"); + if (pos3 != NULL) { + pos2 = pos3; + } else { + pos2 += strlen(pos2); + break; + } + } tempMailTo = estrndup(pos1, pos2 - pos1); + if (pos3 == NULL) { + /* Later, when we remove the Bcc: out of the + header we know it was the last thing. */ + pos2 = pos1; + } } token = strtok(tempMailTo, ","); |