From: Nikita Popov <nikita.ppv@gmail.com>
Date: Tue, 2 Oct 2018 14:13:51 +0000 (+0200)
Subject: Fixed bug #76958
X-Git-Tag: php-7.3.0RC3~30
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26f82a77061b7389c4507a2277643139339b430b;p=php

Fixed bug #76958
---

diff --git a/NEWS b/NEWS
index 906b6a67e8..694e87930f 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,9 @@ PHP                                                                        NEWS
   . Fixed bug #72635 (Undefined class used by class constant in constexpr
     generates fatal error). (Nikita)
 
+- Mbstring:
+  . Fixed bug #76958 (Broken UTF7-IMAP conversion). (Nikita)
+
 27 Sep 2018, PHP 7.3.0RC2
 
 - CURL:
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/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-