From: Moriyoshi Koizumi Date: Wed, 23 Mar 2005 23:30:18 +0000 (+0000) Subject: - MFH: fix bug #32311 (mb_encode_mimeheader() does not properly escape X-Git-Tag: php-4.3.11~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db52703bc2b7309c9a785925e4477a09c8ace137;p=php - MFH: fix bug #32311 (mb_encode_mimeheader() does not properly escape characters). --- diff --git a/NEWS b/NEWS index cea7d64a39..196a16d33a 100644 --- a/NEWS +++ b/NEWS @@ -6,16 +6,17 @@ PHP 4 NEWS and gmp_fact() to prevent SIGFPE. (Tony) - Changed phpize not to require libtool. (Jani) - Updated bundled libmbfl library (used for multibyte functions). (Moriyoshi) -- Fixed bug #32373 (segfault in bzopen() if supplied path to non-existent - file). (Tony) -- Fixed bug #32340 (insert_before($node,NULL) does not return). (Rob) -- Fixed bug #32114 (DOM crashing when attribute appended to Document). (Rob) Fixed bugs: + . Bug #32311 (mb_encode_mimeheader() does not properly escape characters) . Bug #32063 (mb_convert_encoding ignores named entity 'alpha') . Bug #31911 (mb_decode_mimeheader() is case-sensitive to hex escapes) . Bug #30573 (compiler warnings in libmbfl due to invalid type cast) . Bug #30549 (incorrect character translations for some ISO8859 charsets) . Bug #28220 (mb_strwidth() returns wrong width values for some hangul chars) +- Fixed bug #32373 (segfault in bzopen() if supplied path to non-existent + file). (Tony) +- Fixed bug #32340 (insert_before($node,NULL) does not return). (Rob) +- Fixed bug #32114 (DOM crashing when attribute appended to Document). (Rob) - Fixed several leaks in ext/browscap and sapi/embed. (Andrei) - Fixed several leaks in ext/filepro. (Tony) - Fixed build system to always use bundled libtool files. (Jani) diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c index a33991058c..ee1762e38e 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfilter.c +++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c @@ -1960,6 +1960,25 @@ mime_header_encoder_block_collector(int c, void *data) static int mime_header_encoder_collector(int c, void *data) { + static int qp_table[256] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00 */ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */ + 0, 0, 0, 0, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 1, 0, 1, /* 0x10 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 0x50 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 0x70 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xA0 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xB0 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xC0 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xD0 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xE0 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 /* 0xF0 */ + }; + int n; struct mime_header_encoder_data *pe = (struct mime_header_encoder_data *)data; @@ -1969,7 +1988,7 @@ mime_header_encoder_collector(int c, void *data) break; default: /* ASCII */ - if (c >= 0x21 && c < 0x7f) { /* ASCII exclude SPACE and CTLs */ + if (!qp_table[(c & 0xff)]) { /* ordinary characters */ mbfl_memory_device_output(c, &pe->tmpdev); pe->status1 = 1; } else if (pe->status1 == 0 && c == 0x20) { /* repeat SPACE */