[PHP-CVS] cvs: php-src(PHP_5_2) /ext/mbstring mb_gpc.c mbstring.c mbstring.h

2009-03-15 Thread Moriyoshi Koizumi
moriyoshi   Sun Mar 15 20:44:17 2009 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/mbstring   mb_gpc.c mbstring.c mbstring.h 
  Log:
  - MFH: 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.17.2.2.2.5r2=1.17.2.2.2.6diff_format=u
Index: php-src/ext/mbstring/mb_gpc.c
diff -u php-src/ext/mbstring/mb_gpc.c:1.17.2.2.2.5 
php-src/ext/mbstring/mb_gpc.c:1.17.2.2.2.6
--- php-src/ext/mbstring/mb_gpc.c:1.17.2.2.2.5  Wed Dec 31 11:17:39 2008
+++ php-src/ext/mbstring/mb_gpc.c   Sun Mar 15 20:44:17 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mb_gpc.c,v 1.17.2.2.2.5 2008/12/31 11:17:39 sebastian Exp $ */
+/* $Id: mb_gpc.c,v 1.17.2.2.2.6 2009/03/15 20:44:17 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.224.2.22.2.46r2=1.224.2.22.2.47diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.224.2.22.2.46 
php-src/ext/mbstring/mbstring.c:1.224.2.22.2.47
--- php-src/ext/mbstring/mbstring.c:1.224.2.22.2.46 Sun Feb 15 07:11:23 2009
+++ php-src/ext/mbstring/mbstring.c Sun Mar 15 20:44:17 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.224.2.22.2.46 2009/02/15 07:11:23 moriyoshi Exp $ */
+/* $Id: mbstring.c,v 1.224.2.22.2.47 2009/03/15 20:44:17 moriyoshi Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -656,7 +656,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;
@@ -826,7 +826,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);
@@ -927,9 +926,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);
@@ -968,11 +970,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.66.2.4.2.9r2=1.66.2.4.2.10diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.66.2.4.2.9 
php-src/ext/mbstring/mbstring.h:1.66.2.4.2.10
--- php-src/ext/mbstring/mbstring.h:1.66.2.4.2.9Wed Dec 31 11:17:39 2008
+++ php-src/ext/mbstring/mbstring.h Sun Mar 15 20:44:17 2009
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: mbstring.h,v 1.66.2.4.2.9 2008/12/31 11:17:39 sebastian Exp $ */
+/* $Id: mbstring.h,v 1.66.2.4.2.10 2009/03/15 20:44:17 moriyoshi Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring (currently only for Japanese)
@@ -159,6 +159,9 @@
 
 MBSTRING_API int php_mb_stripos(int mode, char *old_haystack, int 
old_haystack_len, char *old_needle, int old_needle_len, long offset, char 
*from_encoding 

[PHP-CVS] cvs: php-src(PHP_5_2) /ext/mbstring mb_gpc.c mbstring.c

2006-11-02 Thread Rui Hirokawa
hirokawaFri Nov  3 02:26:50 2006 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/mbstring   mb_gpc.c mbstring.c 
  Log:
  fixed illegal encoding detection when mbstring.encoding_translation is 
enabled.(made by komura)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mb_gpc.c?r1=1.17.2.2r2=1.17.2.2.2.1diff_format=u
Index: php-src/ext/mbstring/mb_gpc.c
diff -u php-src/ext/mbstring/mb_gpc.c:1.17.2.2 
php-src/ext/mbstring/mb_gpc.c:1.17.2.2.2.1
--- php-src/ext/mbstring/mb_gpc.c:1.17.2.2  Sun Jan  1 12:50:08 2006
+++ php-src/ext/mbstring/mb_gpc.c   Fri Nov  3 02:26:50 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mb_gpc.c,v 1.17.2.2 2006/01/01 12:50:08 sniper Exp $ */
+/* $Id: mb_gpc.c,v 1.17.2.2.2.1 2006/11/03 02:26:50 hirokawa Exp $ */
 
 /* {{{ includes */
 #ifdef HAVE_CONFIG_H
@@ -154,6 +154,8 @@
info.num_from_encodings = MBSTRG(http_input_list_size); 
info.from_language  = MBSTRG(language);
 
+   MBSTRG(illegalchars) = 0;
+
detected = _php_mb_encoding_handler_ex(info, array_ptr, res TSRMLS_CC);
MBSTRG(http_input_identify) = detected;
 
@@ -346,6 +348,7 @@
}
 
if (convd != NULL) {
+   MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
}
if (val_list != NULL) {
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.224.2.22.2.15r2=1.224.2.22.2.16diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.224.2.22.2.15 
php-src/ext/mbstring/mbstring.c:1.224.2.22.2.16
--- php-src/ext/mbstring/mbstring.c:1.224.2.22.2.15 Sun Sep 24 07:10:54 2006
+++ php-src/ext/mbstring/mbstring.c Fri Nov  3 02:26:50 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.224.2.22.2.15 2006/09/24 07:10:54 hirokawa Exp $ */
+/* $Id: mbstring.c,v 1.224.2.22.2.16 2006/11/03 02:26:50 hirokawa Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -933,7 +933,10 @@
MBSTRG(current_http_output_encoding) = MBSTRG(http_output_encoding);
MBSTRG(current_filter_illegal_mode) = MBSTRG(filter_illegal_mode);
MBSTRG(current_filter_illegal_substchar) = 
MBSTRG(filter_illegal_substchar);
-   MBSTRG(illegalchars) = 0;
+
+   if (!MBSTRG(encoding_translation)) {
+   MBSTRG(illegalchars) = 0;
+   }
 
n = 0;
if (MBSTRG(detect_order_list)) {
@@ -4053,8 +4056,13 @@
 
if (ret != NULL) {
MBSTRG(illegalchars) += illegalchars;
-   efree(ret-val);
-   RETURN_BOOL(illegalchars == 0);
+   if (illegalchars == 0  strncmp(string.val, ret-val, 
string.len) == 0) {
+   efree(ret-val);
+   RETURN_TRUE;
+   } else {
+   efree(ret-val);
+   RETURN_FALSE;
+   }
} else {
RETURN_FALSE;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php