[PHP-CVS] cvs: php-src /ext/mbstring mb_gpc.c mbstring.c mbstring.h
moriyoshi Sun Mar 15 20:42:30 2009 UTC Modified files: /php-src/ext/mbstring mb_gpc.c mbstring.c mbstring.h Log: - Fix a bug that mbstring.internal_encoding doesn't take effect within the request encoding converter. http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mb_gpc.c?r1=1.26r2=1.27diff_format=u Index: php-src/ext/mbstring/mb_gpc.c diff -u php-src/ext/mbstring/mb_gpc.c:1.26 php-src/ext/mbstring/mb_gpc.c:1.27 --- php-src/ext/mbstring/mb_gpc.c:1.26 Tue Mar 10 23:39:27 2009 +++ php-src/ext/mbstring/mb_gpc.c Sun Mar 15 20:42:30 2009 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: mb_gpc.c,v 1.26 2009/03/10 23:39:27 helly Exp $ */ +/* $Id: mb_gpc.c,v 1.27 2009/03/15 20:42:30 moriyoshi Exp $ */ /* {{{ includes */ #ifdef HAVE_CONFIG_H @@ -59,6 +59,11 @@ enum mbfl_no_encoding detected; php_mb_encoding_handler_info_t info; + { + char *value = zend_ini_string(mbstring.internal_encoding, sizeof(mbstring.internal_encoding), 0); + _php_mb_ini_mbstring_internal_encoding_set(value, value ? strlen(value): 0 TSRMLS_CC); + } + if (!MBSTRG(encoding_translation)) { php_default_treat_data(arg, str, destArray TSRMLS_CC); return; http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.319r2=1.320diff_format=u Index: php-src/ext/mbstring/mbstring.c diff -u php-src/ext/mbstring/mbstring.c:1.319 php-src/ext/mbstring/mbstring.c:1.320 --- php-src/ext/mbstring/mbstring.c:1.319 Tue Mar 10 23:39:27 2009 +++ php-src/ext/mbstring/mbstring.c Sun Mar 15 20:42:30 2009 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: mbstring.c,v 1.319 2009/03/10 23:39:27 helly Exp $ */ +/* $Id: mbstring.c,v 1.320 2009/03/15 20:42:30 moriyoshi Exp $ */ /* * PHP 4 Multibyte String module mbstring @@ -1032,7 +1032,7 @@ /* }}} */ /* {{{ static _php_mb_ini_mbstring_internal_encoding_set */ -static int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length TSRMLS_DC) +int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length TSRMLS_DC) { enum mbfl_no_encoding no_encoding; const char *enc_name = NULL; @@ -1202,7 +1202,6 @@ if (MBSTRG(encoding_translation)) { sapi_unregister_post_entry(php_post_entries TSRMLS_CC); sapi_register_post_entries(mbstr_post_entries TSRMLS_CC); - sapi_register_treat_data(mbstr_treat_data); } else { sapi_unregister_post_entry(mbstr_post_entries TSRMLS_CC); sapi_register_post_entries(php_post_entries TSRMLS_CC); @@ -1352,9 +1351,12 @@ REGISTER_INI_ENTRIES(); + /* This is a global handler. Should not be set in a per-request handler. */ + sapi_register_treat_data(mbstr_treat_data); + + /* Post handlers are stored in the thread-local context. */ if (MBSTRG(encoding_translation)) { sapi_register_post_entries(mbstr_post_entries TSRMLS_CC); - sapi_register_treat_data(mbstr_treat_data); } REGISTER_LONG_CONSTANT(MB_OVERLOAD_MAIL, MB_OVERLOAD_MAIL, CONST_CS | CONST_PERSISTENT); @@ -1393,11 +1395,6 @@ zend_function *func, *orig; const struct mb_overload_def *p; - { - char *value = zend_ini_string(mbstring.internal_encoding, sizeof(mbstring.internal_encoding), 0); - _php_mb_ini_mbstring_internal_encoding_set(value, value ? strlen(value): 0 TSRMLS_CC); - } - MBSTRG(current_internal_encoding) = MBSTRG(internal_encoding); MBSTRG(current_http_output_encoding) = MBSTRG(http_output_encoding); MBSTRG(current_filter_illegal_mode) = MBSTRG(filter_illegal_mode); http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.h?r1=1.87r2=1.88diff_format=u Index: php-src/ext/mbstring/mbstring.h diff -u php-src/ext/mbstring/mbstring.h:1.87 php-src/ext/mbstring/mbstring.h:1.88 --- php-src/ext/mbstring/mbstring.h:1.87Tue Mar 10 23:39:27 2009 +++ php-src/ext/mbstring/mbstring.h Sun Mar 15 20:42:30 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: mbstring.h,v 1.87 2009/03/10 23:39:27 helly Exp $ */ +/* $Id: mbstring.h,v 1.88 2009/03/15 20:42:30 moriyoshi Exp $ */ /* * PHP 4 Multibyte String module mbstring (currently only for Japanese) @@ -159,6 +159,9 @@ MBSTRING_API int php_mb_stripos(int mode, const char *old_haystack, unsigned int old_haystack_len, const char *old_needle, unsigned int old_needle_len, long offset, const char *from_encoding TSRMLS_DC); +/* internal use only */ +int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length TSRMLS_DC); +
[PHP-CVS] cvs: php-src /ext/mbstring mb_gpc.c mbstring.c mbstring.h /ext/mbstring/libmbfl/mbfl mbfilter.c mbfilter.h
hirokawaSun Dec 25 15:21:54 2005 EDT Modified files: /php-src/ext/mbstring mb_gpc.c mbstring.c mbstring.h /php-src/ext/mbstring/libmbfl/mbfl mbfilter.c mbfilter.h Log: fixed #35711, added mbstring.strict_detection to detect the encoding striktly. http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mb_gpc.c?r1=1.17r2=1.18diff_format=u Index: php-src/ext/mbstring/mb_gpc.c diff -u php-src/ext/mbstring/mb_gpc.c:1.17 php-src/ext/mbstring/mb_gpc.c:1.18 --- php-src/ext/mbstring/mb_gpc.c:1.17 Wed Aug 3 14:07:24 2005 +++ php-src/ext/mbstring/mb_gpc.c Sun Dec 25 15:21:54 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: mb_gpc.c,v 1.17 2005/08/03 14:07:24 sniper Exp $ */ +/* $Id: mb_gpc.c,v 1.18 2005/12/25 15:21:54 hirokawa Exp $ */ /* {{{ includes */ #ifdef HAVE_CONFIG_H @@ -266,7 +266,7 @@ } else { /* auto detect */ from_encoding = mbfl_no_encoding_invalid; - identd = mbfl_encoding_detector_new((enum mbfl_no_encoding *)info-from_encodings, info-num_from_encodings); + identd = mbfl_encoding_detector_new((enum mbfl_no_encoding *)info-from_encodings, info-num_from_encodings, MBSTRG(strict_detection)); if (identd) { n = 0; while (n num) { http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.232r2=1.233diff_format=u Index: php-src/ext/mbstring/mbstring.c diff -u php-src/ext/mbstring/mbstring.c:1.232 php-src/ext/mbstring/mbstring.c:1.233 --- php-src/ext/mbstring/mbstring.c:1.232 Fri Dec 23 11:14:54 2005 +++ php-src/ext/mbstring/mbstring.c Sun Dec 25 15:21:54 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: mbstring.c,v 1.232 2005/12/23 11:14:54 hirokawa Exp $ */ +/* $Id: mbstring.c,v 1.233 2005/12/25 15:21:54 hirokawa Exp $ */ /* * PHP 4 Multibyte String module mbstring @@ -733,6 +733,9 @@ STD_PHP_INI_BOOLEAN(mbstring.encoding_translation, 0, PHP_INI_SYSTEM | PHP_INI_PERDIR, OnUpdate_mbstring_encoding_translation, encoding_translation, zend_mbstring_globals, mbstring_globals) + +STD_PHP_INI_BOOLEAN(mbstring.strict_detection, 0, +PHP_INI_ALL, OnUpdateLong, strict_detection, zend_mbstring_globals, mbstring_globals) PHP_INI_END() /* }}} */ @@ -768,6 +771,7 @@ MBSTRG(current_filter_illegal_substchar) = 0x3f;/* '?' */ MBSTRG(func_overload) = 0; MBSTRG(encoding_translation) = 0; + MBSTRG(strict_detection) = 0; pglobals-outconv = NULL; #if HAVE_MBREGEX _php_mb_regex_globals_ctor(pglobals TSRMLS_CC); @@ -2021,7 +2025,7 @@ string.no_encoding = from_encoding; } else if (size 1) { /* auto detect */ - from_encoding = mbfl_identify_encoding_no(string, list, size); + from_encoding = mbfl_identify_encoding_no(string, list, size, MBSTRG(strict_detection)); if (from_encoding != mbfl_no_encoding_invalid) { string.no_encoding = from_encoding; } else { @@ -2213,7 +2217,7 @@ mbfl_string string; const char *ret; enum mbfl_no_encoding *elist; - int size, *list, strict = 0; + int size, *list, strict; if (ZEND_NUM_ARGS() == 1) { if (zend_get_parameters_ex(1, arg_str) == FAILURE) { @@ -2263,6 +2267,9 @@ convert_to_long_ex(arg_strict); strict = Z_LVAL_PP(arg_strict); } + else { + strict = MBSTRG(strict_detection); + } if (size 0 list != NULL) { elist = list; @@ -2554,7 +2561,7 @@ stack_max = PHP_MBSTR_STACK_BLOCK_SIZE; stack = (zval ***)safe_emalloc(stack_max, sizeof(zval **), 0); stack_level = 0; - identd = mbfl_encoding_detector_new(elist, elistsz); + identd = mbfl_encoding_detector_new(elist, elistsz, MBSTRG(strict_detection)); if (identd != NULL) { n = 2; while (n argc || stack_level 0) { @@ -3173,7 +3180,7 @@ orig_str.no_encoding = MBSTRG(current_internal_encoding); if (orig_str.no_encoding == mbfl_no_encoding_invalid || orig_str.no_encoding == mbfl_no_encoding_pass) { - orig_str.no_encoding = mbfl_identify_encoding_no(orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size)); + orig_str.no_encoding = mbfl_identify_encoding_no(orig_str, MBSTRG(current_detect_order_list), MBSTRG(current_detect_order_list_size), MBSTRG(strict_detection));