summaryrefslogtreecommitdiff
path: root/ext/iconv/iconv.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2018-08-12 23:20:41 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2018-08-25 14:51:13 +0200
commit8754d44167d95a381c9c60beeb26492f4176fe1c (patch)
tree9fb1ceba308c6f13e09dd55377a8a04171d87453 /ext/iconv/iconv.c
parent6e1980e1520306cc5ec7109ccb3d7c8a0a672689 (diff)
downloadphp-git-8754d44167d95a381c9c60beeb26492f4176fe1c.tar.gz
Fix #63839: iconv_mime_decode_headers function is skipping headers
We have to cater to the possibility that `=?` is not the start of an encoded-word, but rather a literal `=?`. If a line break is found while we're still looking for the charset, we can safely assume that it's a literal `=?`, and act accordingly.
Diffstat (limited to 'ext/iconv/iconv.c')
-rw-r--r--ext/iconv/iconv.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index a76b6fd802..dd56ebadca 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -1583,6 +1583,23 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
case '*': /* new style delimiter: locale id follows */
scan_stat = 10;
break;
+
+ case '\r': case '\n': /* not an encoded-word */
+ --p1;
+ _php_iconv_appendc(pretval, '=', cd_pl);
+ _php_iconv_appendc(pretval, '?', cd_pl);
+ err = _php_iconv_appendl(pretval, csname, (size_t)((p1 + 1) - csname), cd_pl);
+ if (err != PHP_ICONV_ERR_SUCCESS) {
+ goto out;
+ }
+ csname = NULL;
+ if ((mode & PHP_ICONV_MIME_DECODE_STRICT)) {
+ scan_stat = 12;
+ }
+ else {
+ scan_stat = 0;
+ }
+ continue;
}
if (scan_stat != 2) {
char tmpbuf[80];