]> granicus.if.org Git - php/commitdiff
- Commit the pending patch (bug #32311).
authorMoriyoshi Koizumi <moriyoshi@php.net>
Wed, 13 Apr 2005 10:10:54 +0000 (10:10 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Wed, 13 Apr 2005 10:10:54 +0000 (10:10 +0000)
# Ugh, it wasn't committed yet.

NEWS
ext/mbstring/libmbfl/mbfl/mbfilter.c

diff --git a/NEWS b/NEWS
index e9e03fbf3997ed354d8b1540ca3f406b99369127..c98ccfd88e3313175df1db470d5de797dc1d2f52 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,7 @@ PHP                                                                        NEWS
   to 3.7.0. (Moriyoshi)
 - Updated bundled libmbfl library (used for multibyte functions). (Moriyoshi)
   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)
index a33991058c63abd9160f2acbd3031ff68268efc4..c6bc2e43488b5dbe1e9d31eae7cabf5ae73c802c 100644 (file)
@@ -571,7 +571,7 @@ mbfl_identify_encoding(mbfl_string *string, enum mbfl_no_encoding *elist, int el
        /* judge */
        encoding = NULL;
 
-       for (i = 0; i < num; i++) {
+       for (i = num; --i >= 0;) {
                filter = &flist[i];
                if (!filter->flag) {
                        encoding = filter->encoding;
@@ -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 */