diff options
Diffstat (limited to 'ext/mbstring')
-rw-r--r-- | ext/mbstring/config.m4 | 10 | ||||
-rw-r--r-- | ext/mbstring/libmbfl/filters/mbfilter_utf16.c | 27 | ||||
-rw-r--r-- | ext/mbstring/libmbfl/filters/mbfilter_utf8.c | 2 | ||||
-rw-r--r-- | ext/mbstring/libmbfl/mbfl/mbfilter.c | 2 | ||||
-rw-r--r-- | ext/mbstring/mb_gpc.c | 4 | ||||
-rw-r--r-- | ext/mbstring/mbstring.c | 8 | ||||
-rw-r--r-- | ext/mbstring/mbstring.h | 4 | ||||
-rw-r--r-- | ext/mbstring/php_mbregex.c | 4 | ||||
-rw-r--r-- | ext/mbstring/php_mbregex.h | 4 | ||||
-rw-r--r-- | ext/mbstring/php_unicode.c | 2 | ||||
-rw-r--r-- | ext/mbstring/php_unicode.h | 2 | ||||
-rw-r--r-- | ext/mbstring/tests/bug43994.phpt | 2 | ||||
-rw-r--r-- | ext/mbstring/tests/bug45722.phpt | 2 | ||||
-rw-r--r-- | ext/mbstring/tests/bug47399.phpt | 2 | ||||
-rw-r--r-- | ext/mbstring/tests/bug48697.phpt | 24 | ||||
-rw-r--r-- | ext/mbstring/tests/bug49354.phpt | 21 | ||||
-rw-r--r-- | ext/mbstring/tests/bug49528.phpt | 20 | ||||
-rw-r--r-- | ext/mbstring/tests/bug49536.phpt | 20 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_encoding_aliases.phpt | 2 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_list_encodings.phpt | 2 |
20 files changed, 130 insertions, 34 deletions
diff --git a/ext/mbstring/config.m4 b/ext/mbstring/config.m4 index ad0c16c41..ef7678347 100644 --- a/ext/mbstring/config.m4 +++ b/ext/mbstring/config.m4 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4 279059 2009-04-20 15:39:48Z jani $ +dnl $Id: config.m4 291283 2009-11-25 01:30:06Z rasmus $ dnl AC_DEFUN([PHP_MBSTRING_ADD_SOURCES], [ @@ -74,7 +74,7 @@ AC_DEFUN([PHP_MBSTRING_SETUP_MBREGEX], [ AC_DEFINE([USE_COMBINATION_EXPLOSION_CHECK],1,[whether to check multibyte regex backtrack]) fi - AC_CACHE_CHECK(for variable length prototypes and stdarg.h, cv_php_mbstring_stdarg, [ + AC_CACHE_CHECK(for variable length prototypes and stdarg.h, php_cv_mbstring_stdarg, [ AC_TRY_RUN([ #include <stdarg.h> int foo(int x, ...) { @@ -86,14 +86,14 @@ int foo(int x, ...) { return 0; } int main() { return foo(10, "", 3.14); } - ], [cv_php_mbstring_stdarg=yes], [cv_php_mbstring_stdarg=no], [ + ], [php_cv_mbstring_stdarg=yes], [php_cv_mbstring_stdarg=no], [ dnl cross-compile needs something here case $host_alias in *netware*) - cv_php_mbstring_stdarg=yes + php_cv_mbstring_stdarg=yes ;; *) - cv_php_mbstring_stdarg=no + php_cv_mbstring_stdarg=no ;; esac ]) diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf16.c b/ext/mbstring/libmbfl/filters/mbfilter_utf16.c index b6c2aeda5..5df6551d4 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_utf16.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_utf16.c @@ -127,7 +127,7 @@ int mbfl_filt_conv_utf16_wchar(int c, mbfl_convert_filter *filter) int n, endian; endian = filter->status & 0xff00; - switch (filter->status & 0xff) { + switch (filter->status & 0x0f) { case 0: if (endian) { n = c & 0xff; @@ -144,15 +144,8 @@ int mbfl_filt_conv_utf16_wchar(int c, mbfl_convert_filter *filter) n = c & 0xff; } n |= filter->cache & 0xffff; - filter->status &= ~0xff; - if (n == 0xfffe) { - if (endian) { - filter->status = 0; /* big-endian */ - } else { - filter->status = 0x100; /* little-endian */ - } - CK((*filter->output_function)(0xfeff, filter->data)); - } else if (n >= 0xd800 && n < 0xdc00) { + filter->status &= ~0x0f; + if (n >= 0xd800 && n < 0xdc00) { filter->cache = ((n & 0x3ff) << 16) + 0x400000; } else if (n >= 0xdc00 && n < 0xe000) { n &= 0x3ff; @@ -166,7 +159,21 @@ int mbfl_filt_conv_utf16_wchar(int c, mbfl_convert_filter *filter) CK((*filter->output_function)(n, filter->data)); } } else { + int is_first = filter->status & 0x10; filter->cache = 0; + filter->status |= 0x10; + if (!is_first) { + if (n == 0xfffe) { + if (endian) { + filter->status &= ~0x100; /* big-endian */ + } else { + filter->status |= 0x100; /* little-endian */ + } + break; + } else if (n == 0xfeff) { + break; + } + } CK((*filter->output_function)(n, filter->data)); } break; diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf8.c b/ext/mbstring/libmbfl/filters/mbfilter_utf8.c index 20ff983e1..c6777b29f 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_utf8.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_utf8.c @@ -220,7 +220,7 @@ static int mbfl_filt_ident_utf8(int c, mbfl_identify_filter *filter) if (c < 0x80) { if (c < 0) { filter->flag = 1; /* bad */ - } else if (c != 0 && filter->status) { + } else if (filter->status) { filter->flag = 1; /* bad */ } filter->status = 0; diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c index 1aeb38cc9..4997c5a88 100644 --- a/ext/mbstring/libmbfl/mbfl/mbfilter.c +++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c @@ -622,7 +622,7 @@ mbfl_identify_encoding(mbfl_string *string, enum mbfl_no_encoding *elist, int el if (!encoding) { for (i = 0; i < num; i++) { filter = &flist[i]; - if (!filter->flag) { + if (!filter->flag && (!strict || !filter->status)) { encoding = filter->encoding; break; } diff --git a/ext/mbstring/mb_gpc.c b/ext/mbstring/mb_gpc.c index b7dfd57dd..688a55dea 100644 --- a/ext/mbstring/mb_gpc.c +++ b/ext/mbstring/mb_gpc.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mb_gpc.c 284727 2009-07-24 23:48:58Z moriyoshi $ */ +/* $Id: mb_gpc.c 293036 2010-01-03 09:23:27Z sebastian $ */ /* {{{ includes */ #ifdef HAVE_CONFIG_H diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 3e46e8239..2d245979e 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c 281226 2009-05-27 13:42:17Z tony2001 $ */ +/* $Id: mbstring.c 293036 2010-01-03 09:23:27Z sebastian $ */ /* * PHP 4 Multibyte String module "mbstring" @@ -2665,10 +2665,6 @@ PHP_FUNCTION(mb_strcut) RETURN_FALSE; } - if (((unsigned int)from + (unsigned int)len) > string.len) { - len = string.len - from; - } - ret = mbfl_strcut(&string, &result, from, len); if (ret == NULL) { RETURN_FALSE; diff --git a/ext/mbstring/mbstring.h b/ext/mbstring/mbstring.h index ee0f8b8d2..52d0b40c7 100644 --- a/ext/mbstring/mbstring.h +++ b/ext/mbstring/mbstring.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.h 277211 2009-03-15 20:42:56Z moriyoshi $ */ +/* $Id: mbstring.h 293036 2010-01-03 09:23:27Z sebastian $ */ /* * PHP 4 Multibyte String module "mbstring" (currently only for Japanese) diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index a3c577848..d9bac43f8 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mbregex.c 281727 2009-06-05 18:50:32Z mattwil $ */ +/* $Id: php_mbregex.c 293036 2010-01-03 09:23:27Z sebastian $ */ #ifdef HAVE_CONFIG_H diff --git a/ext/mbstring/php_mbregex.h b/ext/mbstring/php_mbregex.h index c9201df3f..dcc840f42 100644 --- a/ext/mbstring/php_mbregex.h +++ b/ext/mbstring/php_mbregex.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mbregex.h 272370 2008-12-31 11:15:49Z sebastian $ */ +/* $Id: php_mbregex.h 293036 2010-01-03 09:23:27Z sebastian $ */ #ifndef _PHP_MBREGEX_H #define _PHP_MBREGEX_H diff --git a/ext/mbstring/php_unicode.c b/ext/mbstring/php_unicode.c index bb17c166d..55d7d5128 100644 --- a/ext/mbstring/php_unicode.c +++ b/ext/mbstring/php_unicode.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mbstring/php_unicode.h b/ext/mbstring/php_unicode.h index e35193df1..1afd3f974 100644 --- a/ext/mbstring/php_unicode.h +++ b/ext/mbstring/php_unicode.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/mbstring/tests/bug43994.phpt b/ext/mbstring/tests/bug43994.phpt index 39a39f642..8fdb904a7 100644 --- a/ext/mbstring/tests/bug43994.phpt +++ b/ext/mbstring/tests/bug43994.phpt @@ -38,7 +38,7 @@ foreach($inputs as $input) { }; ?> ---EXPECTF---- +--EXPECTF-- -- Iteration 1 -- Without $regs arg: diff --git a/ext/mbstring/tests/bug45722.phpt b/ext/mbstring/tests/bug45722.phpt index c05a010a8..97f6fe5d9 100644 --- a/ext/mbstring/tests/bug45722.phpt +++ b/ext/mbstring/tests/bug45722.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #45722 (mb_check_encoding() crashes) +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> --FILE-- <?php var_dump(mb_check_encoding("&\xc2\xb7 TEST TEST TEST TEST TEST TEST", "HTML-ENTITIES")); diff --git a/ext/mbstring/tests/bug47399.phpt b/ext/mbstring/tests/bug47399.phpt index 79618688a..3586e5cc7 100644 --- a/ext/mbstring/tests/bug47399.phpt +++ b/ext/mbstring/tests/bug47399.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #47399 (mb_check_encoding() returns true for some illegal SJIS characters) +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> --FILE-- <?php foreach (array("Shift_JIS", "CP932") as $enc) { diff --git a/ext/mbstring/tests/bug48697.phpt b/ext/mbstring/tests/bug48697.phpt new file mode 100644 index 000000000..42bbe9f5a --- /dev/null +++ b/ext/mbstring/tests/bug48697.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #48697 (mb_internal_encoding() value gets reset by parse_str() or mb_parse_str() +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> +--FILE-- +<?php +ini_set('mbstring.internal_encoding', 'ISO-8859-15'); +ini_set('mbstring.encoding_translation', true); +var_dump(mb_internal_encoding()); +mb_internal_encoding('UTF-8'); +var_dump(mb_internal_encoding()); +parse_str('a=b'); +var_dump(mb_internal_encoding()); +mb_internal_encoding('UTF-8'); +var_dump(mb_internal_encoding()); +parse_str('a=b'); +var_dump(mb_internal_encoding()); +?> +--EXPECT-- +string(11) "ISO-8859-15" +string(5) "UTF-8" +string(5) "UTF-8" +string(5) "UTF-8" +string(5) "UTF-8" diff --git a/ext/mbstring/tests/bug49354.phpt b/ext/mbstring/tests/bug49354.phpt new file mode 100644 index 000000000..c25b405d8 --- /dev/null +++ b/ext/mbstring/tests/bug49354.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #49354 (mb_strcut() cuts wrong length when offset is in the middle of a multibyte character) +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> +--FILE-- +<?php +$crap = 'AåBäCöDü'; +var_dump(mb_strcut($crap, 0, 100, 'UTF-8')); +var_dump(mb_strcut($crap, 1, 100, 'UTF-8')); +var_dump(mb_strcut($crap, 2, 100, 'UTF-8')); +var_dump(mb_strcut($crap, 3, 100, 'UTF-8')); +var_dump(mb_strcut($crap, 12, 100, 'UTF-8')); +var_dump(mb_strcut($crap, 13, 100, 'UTF-8')); +?> +--EXPECT-- +string(12) "AåBäCöDü" +string(11) "åBäCöDü" +string(11) "åBäCöDü" +string(9) "BäCöDü" +string(0) "" +bool(false) diff --git a/ext/mbstring/tests/bug49528.phpt b/ext/mbstring/tests/bug49528.phpt new file mode 100644 index 000000000..b06c35f85 --- /dev/null +++ b/ext/mbstring/tests/bug49528.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #49528 (UTF-16 strings prefixed by BOM wrongly converted) +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> +--FILE-- +<?php +var_dump(bin2hex(mb_convert_encoding("\xff\xfe\x01\x02\x03\x04", "UCS-2BE", "UTF-16"))); +var_dump(bin2hex(mb_convert_encoding("\xfe\xff\x01\x02\x03\x04", "UCS-2BE", "UTF-16"))); +var_dump(bin2hex(mb_convert_encoding("\xff\xfe\xff\xfe\x01\x02\x03\x04", "UCS-2BE", "UTF-16"))); +var_dump(bin2hex(mb_convert_encoding("\xff\xfe\xfe\xff\x01\x02\x03\x04", "UCS-2BE", "UTF-16"))); +var_dump(bin2hex(mb_convert_encoding("\xfe\xff\xff\xfe\x01\x02\x03\x04", "UCS-2BE", "UTF-16"))); +var_dump(bin2hex(mb_convert_encoding("\xfe\xff\xfe\xff\x01\x02\x03\x04", "UCS-2BE", "UTF-16"))); +?> +--EXPECT-- +string(8) "02010403" +string(8) "01020304" +string(12) "feff02010403" +string(12) "fffe02010403" +string(12) "fffe01020304" +string(12) "feff01020304" diff --git a/ext/mbstring/tests/bug49536.phpt b/ext/mbstring/tests/bug49536.phpt new file mode 100644 index 000000000..32685d226 --- /dev/null +++ b/ext/mbstring/tests/bug49536.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #49536 (mb_detect_encoding() returns incorrect results when strict_mode is turned on) +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> +--FILE-- +<?php +// non-strict mode +var_dump(mb_detect_encoding("A\x81", "SJIS", false)); +// strict mode +var_dump(mb_detect_encoding("A\x81", "SJIS", true)); +// non-strict mode +var_dump(mb_detect_encoding("\xc0\x00", "UTF-8", false)); +// strict mode +var_dump(mb_detect_encoding("\xc0\x00", "UTF-8", true)); +?> +--EXPECT-- +string(4) "SJIS" +bool(false) +string(5) "UTF-8" +bool(false) diff --git a/ext/mbstring/tests/mb_encoding_aliases.phpt b/ext/mbstring/tests/mb_encoding_aliases.phpt index 7b87045d0..2159481ef 100644 --- a/ext/mbstring/tests/mb_encoding_aliases.phpt +++ b/ext/mbstring/tests/mb_encoding_aliases.phpt @@ -1,5 +1,7 @@ --TEST-- mb_encoding_aliases() +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> --FILE-- <?php mb_encoding_aliases(); diff --git a/ext/mbstring/tests/mb_list_encodings.phpt b/ext/mbstring/tests/mb_list_encodings.phpt index e155cb851..135a9ef67 100644 --- a/ext/mbstring/tests/mb_list_encodings.phpt +++ b/ext/mbstring/tests/mb_list_encodings.phpt @@ -1,5 +1,7 @@ --TEST-- mb_list_encodings +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> --FILE-- <?php var_dump(in_array("7bit", mb_list_encodings())); |