From: Moriyoshi Koizumi Date: Mon, 6 Jan 2003 15:35:42 +0000 (+0000) Subject: Fixed iconv_mime_decode() so that it comforms to RFC2231 X-Git-Tag: PHP_5_0_dev_before_13561_fix~424 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f44489b689a0362f30c6e2c2cfdd5c080afd80d;p=php Fixed iconv_mime_decode() so that it comforms to RFC2231 --- diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index c9a73f9e23..5347ccbe96 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -1281,14 +1281,21 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st switch (scan_stat) { case 0: - if (*p1 == '\r') { - scan_stat = 7; - } else if (*p1 == '\n') { - scan_stat = 8; - } else if (*p1 == '=') { - scan_stat = 1; - } else { - _php_iconv_appendc(pretval, *p1, cd_pl); + switch (*p1) { + case '\r': + scan_stat = 7; + break; + + case '\n': + scan_stat = 8; + break; + + case '=': + scan_stat = 1; + break; + + default: + _php_iconv_appendc(pretval, *p1, cd_pl); } break; @@ -1302,7 +1309,16 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st break; case 2: /* charset name */ - if (*p1 == '?') { + switch (*p1) { + case '?': + scan_stat = 3; + break; + + case '*': + scan_stat = 10; + break; + } + if (scan_stat != 2) { char tmpbuf[80]; if (csname == NULL) { @@ -1338,8 +1354,6 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st #endif goto out; } - - scan_stat = 3; } break; @@ -1438,6 +1452,12 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st goto out; } break; + + case 10: /* language spec */ + if (*p1 == '?') { + scan_stat = 3; + } + break; } }