From: Moriyoshi Koizumi Date: Fri, 6 Feb 2009 08:49:05 +0000 (+0000) Subject: - MFH: Fix bug #45239 (encoding detector hangs with mbstring.strict_detection X-Git-Tag: php-5.2.9RC2~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9407016127865b4f028b52314d9793986fc1440;p=php - MFH: Fix bug #45239 (encoding detector hangs with mbstring.strict_detection enabled). --- diff --git a/NEWS b/NEWS index c9b00f4778..f432c8aa21 100644 --- a/NEWS +++ b/NEWS @@ -56,7 +56,8 @@ PHP NEWS - Fixed bug #46887 (Invalid calls to php_error_docref()). (oeriksson at mandriva dot com, Ilia) - Fixed bug #46873 (extract($foo) crashes if $foo['foo'] exists). (Arnaud) -- Fixed bug #46843 (CP936 euro symbol is not converted properly). (Moriyoshi) +- Fixed bug #46843 (CP936 euro symbol is not converted properly). + (ty_c at cybozuy dot co dot jp, Moriyoshi) - Fixed bug #46798 (Crash in mssql extension when retrieving a NULL value inside a binary or image column type). (Ilia) - Fixed bug #46782 (fastcgi.c parse error). (Matt) @@ -74,6 +75,8 @@ PHP NEWS (admorten at umich dot edu, Stas) - Fixed bug #45996 (libxml2 2.7 causes breakage with character data in xml_parse()). (Rob) +- Fixed bug #45239 (Encoding detector hangs with mbstring.strict_detection + enabled). (Moriyoshi) - Fixed bug #45161 (Reusing a curl handle leaks memory). (Mark Karpeles, Jani) - Fixed bug #44336 (Improve pcre UTF-8 string matching performance). (frode at coretrek dot com, Nuno) diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c index 50a0853665..a2c117d2a3 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfilter.c +++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c @@ -462,10 +462,9 @@ enum mbfl_no_encoding mbfl_encoding_detector_judge(mbfl_encoding_detector *ident while (n >= 0) { filter = identd->filter_list[n]; if (!filter->flag) { - if (identd->strict && filter->status) { - continue; + if (!identd->strict || !filter->status) { + encoding = filter->encoding->no_encoding; } - encoding = filter->encoding->no_encoding; } n--; } diff --git a/ext/mbstring/tests/bug45239.phpt b/ext/mbstring/tests/bug45239.phpt new file mode 100644 index 0000000000..8d8ef4831e --- /dev/null +++ b/ext/mbstring/tests/bug45239.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #45239 (encoding detector hangs with mbstring.strict_detection enabled) +--INI-- +mbstring.strict_detection=1 +mbstring.http_input=UTF-8 +mbstring.internal_encoding=UTF-8 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(5) "UTF-8"