diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2018-10-02 16:14:36 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2018-10-02 16:14:36 +0200 |
commit | aec64214091ed97de5ae7584c5b133a4699a9c70 (patch) | |
tree | 4f3579ea4f731af39c7e5e931f85c3896d73638c | |
parent | 9bfb97241367445234675dc103bc0c93fcfc55dc (diff) | |
parent | 26f82a77061b7389c4507a2277643139339b430b (diff) | |
download | php-git-aec64214091ed97de5ae7584c5b133a4699a9c70.tar.gz |
Merge branch 'PHP-7.3'
-rw-r--r-- | ext/mbstring/libmbfl/filters/mbfilter_utf7imap.c | 4 | ||||
-rw-r--r-- | ext/mbstring/libmbfl/mbfl/mbfilter.c | 5 | ||||
-rw-r--r-- | ext/mbstring/libmbfl/mbfl/mbfl_convert.c | 7 | ||||
-rw-r--r-- | ext/mbstring/tests/bug76958.phpt | 14 |
4 files changed, 25 insertions, 5 deletions
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf7imap.c b/ext/mbstring/libmbfl/filters/mbfilter_utf7imap.c index 72c772b072..d95c5dbaa9 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_utf7imap.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_utf7imap.c @@ -40,7 +40,9 @@ const mbfl_encoding mbfl_encoding_utf7imap = { NULL, NULL, NULL, - MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE + MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE, + &vtbl_utf7imap_wchar, + &vtbl_wchar_utf7imap }; const struct mbfl_convert_vtbl vtbl_utf7imap_wchar = { diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c index 6821063136..331ce4941c 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfilter.c +++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c @@ -136,7 +136,7 @@ mbfl_buffer_converter_new( /* create convert filter */ convd->filter1 = NULL; -convd->filter2 = NULL; + convd->filter2 = NULL; if (mbfl_convert_filter_get_vtbl(convd->from, convd->to) != NULL) { convd->filter1 = mbfl_convert_filter_new(convd->from, convd->to, mbfl_memory_device_output, NULL, &convd->device); } else { @@ -153,6 +153,7 @@ convd->filter2 = NULL; } } if (convd->filter1 == NULL) { + mbfl_free(convd); return NULL; } @@ -2388,7 +2389,7 @@ mime_header_decoder_new(const mbfl_encoding *outcode) mbfl_memory_device_init(&pd->tmpdev, 0, 0); pd->cspos = 0; pd->status = 0; - pd->encoding = &mbfl_encoding_pass; + pd->encoding = &mbfl_encoding_8bit; pd->incode = &mbfl_encoding_ascii; pd->outcode = outcode; /* charset convert filter */ diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_convert.c b/ext/mbstring/libmbfl/mbfl/mbfl_convert.c index 9e900ddfca..c201bd93c6 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfl_convert.c +++ b/ext/mbstring/libmbfl/mbfl/mbfl_convert.c @@ -169,9 +169,8 @@ mbfl_convert_filter_new( const struct mbfl_convert_vtbl *vtbl; vtbl = mbfl_convert_filter_get_vtbl(from, to); - if (vtbl == NULL) { - vtbl = &vtbl_pass; + return NULL; } /* allocate */ @@ -452,6 +451,10 @@ const struct mbfl_convert_vtbl * mbfl_convert_filter_get_vtbl( to = &mbfl_encoding_8bit; } + if (to == from && (to == &mbfl_encoding_wchar || to == &mbfl_encoding_8bit)) { + return &vtbl_pass; + } + if (to->no_encoding == mbfl_no_encoding_wchar) { return from->input_filter; } else if (from->no_encoding == mbfl_no_encoding_wchar) { diff --git a/ext/mbstring/tests/bug76958.phpt b/ext/mbstring/tests/bug76958.phpt new file mode 100644 index 0000000000..a7d6112936 --- /dev/null +++ b/ext/mbstring/tests/bug76958.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #76958: Broken UTF7-IMAP conversion +--FILE-- +<?php + +$str = '&BCAEMARBBEEESwQ7BDoEOA-'; +echo mb_convert_encoding($str, 'UTF-8', 'UTF7-IMAP') . "\n"; +$str = 'Рассылки'; +echo mb_convert_encoding($str, 'UTF7-IMAP', 'UTF-8') . "\n"; + +?> +--EXPECT-- +Рассылки +&BCAEMARBBEEESwQ7BDoEOA- |