[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /ext/mbstring/libmbfl/mbfl mbfilter.c /ext/mbstring/tests bug45923.phpt

2009-02-13 Thread Moriyoshi Koizumi
moriyoshi   Sat Feb 14 07:33:41 2009 UTC

  Added files: 
/php-src/ext/mbstring/tests bug45923.phpt 

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
/php-src/ext/mbstring/libmbfl/mbfl  mbfilter.c 
  Log:
  - Fix Bug #45923 (mb_st[r]ripos() offset not handled correctly)
  # test still fails because of the difference of str[r]pos() behavior between 
5.3 and 6.0.
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.314r2=1.315diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.314 
php-src/ext/mbstring/mbstring.c:1.315
--- php-src/ext/mbstring/mbstring.c:1.314   Wed Feb 11 14:26:53 2009
+++ php-src/ext/mbstring/mbstring.c Sat Feb 14 07:33:41 2009
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.314 2009/02/11 14:26:53 iliaa Exp $ */
+/* $Id: mbstring.c,v 1.315 2009/02/14 07:33:41 moriyoshi Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -2075,8 +2075,8 @@
}
}
 
-   if (offset  0 || (unsigned long)offset  haystack.len) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset not 
contained in string.);
+   if (offset  0 || offset  mbfl_strlen(haystack)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset not 
contained in string);
RETURN_FALSE;
}
if (needle.len == 0) {
@@ -2092,17 +2092,17 @@
case 1:
break;
case 2:
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Needle has 
not positive length.);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Needle has 
not positive length);
break;
case 4:
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown 
encoding or conversion error.);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown 
encoding or conversion error);
break;
case 8:
-   php_error_docref(NULL TSRMLS_CC, E_NOTICE, Argument is 
empty.);
+   php_error_docref(NULL TSRMLS_CC, E_NOTICE, Argument is 
empty);
break;
default:
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown 
error in mb_strpos.);
-   break;  
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown 
error in mb_strpos);
+   break;
}
RETVAL_FALSE;
}
@@ -2188,6 +2188,16 @@
if (needle.len = 0) {
RETURN_FALSE;
}
+
+   {
+   int haystack_char_len = mbfl_strlen(haystack);
+   if ((offset  0  offset  haystack_char_len) ||
+   (offset  0  -offset  haystack_char_len)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset is 
greater than the length of haystack string);
+   RETURN_FALSE;
+   }
+   }
+
n = mbfl_strpos(haystack, needle, offset, 1);
if (n = 0) {
RETVAL_LONG(n);
@@ -2242,10 +2252,6 @@
RETURN_FALSE;
}
 
-   if ((unsigned int)offset  haystack.len) {
-   RETURN_FALSE;
-   }
-
n = php_mb_stripos(1, (char *)haystack.val, haystack.len, (char 
*)needle.val, needle.len, offset, from_encoding TSRMLS_CC);
 
if (n = 0) {
@@ -4636,7 +4642,7 @@
 
 /* {{{ MBSTRING_API int php_mb_stripos()
  */
-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, 
unsigned int offset, const char *from_encoding TSRMLS_DC)
+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)
 {
int n;
mbfl_string haystack, needle;
@@ -4679,9 +4685,21 @@
break;
}
 
-   if (offset  0 || offset  haystack.len) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset not 
contained in string.);
-   break;
+   {
+   int haystack_char_len = mbfl_strlen(haystack);
+ 
+   if (mode) {
+   if ((offset  0  offset  haystack_char_len) 
||
+   (offset  0  -offset  
haystack_char_len)) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, Offset is greater than the length of haystack string);
+   break;
+   }
+   } else {
+  

[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2008-09-12 Thread Moriyoshi Koizumi
moriyoshi   Sat Sep 13 00:22:10 2008 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
  Log:
  - mb_encoding_aliases() is more consistent with mb_preferred_mime_name()
despite the unconformance with the naming convention.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.300r2=1.301diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.300 
php-src/ext/mbstring/mbstring.c:1.301
--- php-src/ext/mbstring/mbstring.c:1.300   Fri Sep 12 23:59:51 2008
+++ php-src/ext/mbstring/mbstring.c Sat Sep 13 00:22:10 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.300 2008/09/12 23:59:51 moriyoshi Exp $ */
+/* $Id: mbstring.c,v 1.301 2008/09/13 00:22:10 moriyoshi Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -393,7 +393,7 @@
 ZEND_END_ARG_INFO()
 
 static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_list_encoding_aliases, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_encoding_aliases, 0, 0, 1)
ZEND_ARG_INFO(0, encoding)
 ZEND_END_ARG_INFO()
 
@@ -582,7 +582,7 @@
PHP_FE(mb_convert_encoding, arginfo_mb_convert_encoding)
PHP_FE(mb_detect_encoding,  arginfo_mb_detect_encoding)
PHP_FE(mb_list_encodings,   arginfo_mb_list_encodings)
-   PHP_FE(mb_list_encoding_aliases,
arginfo_mb_list_encoding_aliases)
+   PHP_FE(mb_encoding_aliases, arginfo_mb_encoding_aliases)
PHP_FE(mb_convert_kana, arginfo_mb_convert_kana)
PHP_FE(mb_encode_mimeheader,arginfo_mb_encode_mimeheader)
PHP_FE(mb_decode_mimeheader,arginfo_mb_decode_mimeheader)
@@ -3140,9 +3140,9 @@
 }
 /* }}} */
 
-/* {{{ proto array mb_list_encoding_aliases(string encoding)
+/* {{{ proto array mb_encoding_aliases(string encoding)
Returns an array of the aliases of a given encoding name */
-PHP_FUNCTION(mb_list_encoding_aliases)
+PHP_FUNCTION(mb_encoding_aliases)
 {
const mbfl_encoding *encoding;
char *name = NULL;
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.h?r1=1.83r2=1.84diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.83 
php-src/ext/mbstring/mbstring.h:1.84
--- php-src/ext/mbstring/mbstring.h:1.83Sat Aug  2 20:48:30 2008
+++ php-src/ext/mbstring/mbstring.h Sat Sep 13 00:22:10 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: mbstring.h,v 1.83 2008/08/02 20:48:30 moriyoshi Exp $ */
+/* $Id: mbstring.h,v 1.84 2008/09/13 00:22:10 moriyoshi Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring (currently only for Japanese)
@@ -117,8 +117,7 @@
 PHP_FUNCTION(mb_convert_encoding);
 PHP_FUNCTION(mb_detect_encoding);
 PHP_FUNCTION(mb_list_encodings);
-PHP_FUNCTION(mb_list_encodings_alias_names);
-PHP_FUNCTION(mb_list_mime_names);
+PHP_FUNCTION(mb_encoding_aliases);
 PHP_FUNCTION(mb_convert_kana);
 PHP_FUNCTION(mb_encode_mimeheader);
 PHP_FUNCTION(mb_decode_mimeheader);



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



[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2008-08-02 Thread Moriyoshi Koizumi
moriyoshi   Sat Aug  2 20:48:30 2008 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
  Log:
  - Fixed bug #45691 (Some per-dir or runtime settings may leak into other 
requests).
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.291r2=1.292diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.291 
php-src/ext/mbstring/mbstring.c:1.292
--- php-src/ext/mbstring/mbstring.c:1.291   Fri Jul 25 14:04:39 2008
+++ php-src/ext/mbstring/mbstring.c Sat Aug  2 20:48:30 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.291 2008/07/25 14:04:39 moriyoshi Exp $ */
+/* $Id: mbstring.c,v 1.292 2008/08/02 20:48:30 moriyoshi Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -1013,6 +1013,7 @@
 
no_language = mbfl_name2no_language(new_value);
if (no_language == mbfl_no_language_invalid) {
+   MBSTRG(language) = mbfl_no_language_neutral;
return FAILURE;
}
MBSTRG(language) = no_language;
@@ -1028,12 +1029,16 @@
int size;
 
if (php_mb_parse_encoding_list(new_value, new_value_length, list, 
size, 1 TSRMLS_CC)) {
-   if (MBSTRG(detect_order_list) != NULL) {
+   if (MBSTRG(detect_order_list)) {
free(MBSTRG(detect_order_list));
}
MBSTRG(detect_order_list) = list;
MBSTRG(detect_order_list_size) = size;
} else {
+   if (MBSTRG(detect_order_list)) {
+   free(MBSTRG(detect_order_list));
+   MBSTRG(detect_order_list) = NULL;
+   }
return FAILURE;
}
 
@@ -1048,12 +1053,17 @@
int size;
 
if (php_mb_parse_encoding_list(new_value, new_value_length, list, 
size, 1 TSRMLS_CC)) {
-   if (MBSTRG(http_input_list) != NULL) {
+   if (MBSTRG(http_input_list)) {
free(MBSTRG(http_input_list));
}
MBSTRG(http_input_list) = list;
MBSTRG(http_input_list_size) = size;
} else {
+   if (MBSTRG(http_input_list)) {
+   free(MBSTRG(http_input_list));
+   MBSTRG(http_input_list) = NULL;
+   }
+   MBSTRG(http_input_list_size) = 0;
return FAILURE;
}
 
@@ -1071,6 +1081,8 @@
MBSTRG(http_output_encoding) = no_encoding;
MBSTRG(current_http_output_encoding) = no_encoding;
} else {
+   MBSTRG(http_output_encoding) = mbfl_no_encoding_pass;
+   MBSTRG(current_http_output_encoding) = mbfl_no_encoding_pass;
if (new_value != NULL  new_value_length  0) {
return FAILURE;
}
@@ -1084,34 +1096,75 @@
 static PHP_INI_MH(OnUpdate_mbstring_internal_encoding)
 {
enum mbfl_no_encoding no_encoding;
-   if (new_value == NULL) {
-   return SUCCESS;
-   }
-
-   no_encoding = mbfl_name2no_encoding(new_value);
+   const char *enc_name = NULL;
+   uint enc_name_len = 0;
+  
+   no_encoding = new_value ? mbfl_name2no_encoding(new_value):
+   mbfl_no_encoding_invalid;
if (no_encoding != mbfl_no_encoding_invalid) {
-   MBSTRG(internal_encoding) = no_encoding;
-   MBSTRG(current_internal_encoding) = no_encoding;
+   enc_name = new_value;
+   enc_name_len = new_value_length;
+   } else {
+   switch (MBSTRG(language)) {
+   case mbfl_no_language_uni:
+   enc_name = UTF-8;
+   enc_name_len = sizeof(UTF-8) - 1;
+   break;
+   case mbfl_no_language_japanese:
+   enc_name = EUC-JP;
+   enc_name_len = sizeof(EUC-JP) - 1;
+   break;
+   case mbfl_no_language_korean:
+   enc_name = EUC-KR;
+   enc_name_len = sizeof(EUC-KR) - 1;
+   break;
+   case mbfl_no_language_simplified_chinese:
+   enc_name = EUC-CN;
+   enc_name_len = sizeof(EUC-CN) - 1;
+   break;
+   case mbfl_no_language_traditional_chinese:
+   enc_name = EUC-TW;
+   enc_name_len = sizeof(EUC-TW) - 1;
+   break;
+   case mbfl_no_language_russian:
+   enc_name = KOI8-R;
+   enc_name_len = sizeof(KOI8-R) - 1;

[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h php_unicode.c php_unicode.h

2008-07-24 Thread Moriyoshi Koizumi
moriyoshi   Thu Jul 24 13:46:35 2008 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h php_unicode.c 
php_unicode.h 
  Log:
  - Fixed warnings.
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.287r2=1.288diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.287 
php-src/ext/mbstring/mbstring.c:1.288
--- php-src/ext/mbstring/mbstring.c:1.287   Thu Jul 24 12:58:37 2008
+++ php-src/ext/mbstring/mbstring.c Thu Jul 24 13:46:35 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.287 2008/07/24 12:58:37 moriyoshi Exp $ */
+/* $Id: mbstring.c,v 1.288 2008/07/24 13:46:35 moriyoshi Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -2230,17 +2230,17 @@
 {
int n;
long offset;
-   char *old_haystack, *old_needle;
+   mbfl_string haystack, needle;
char *from_encoding = 
(char*)mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding));
-   int old_haystack_len, old_needle_len, from_encoding_len;
+   int from_encoding_len;
n = -1;
offset = 0;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|ls, 
old_haystack, old_haystack_len, old_needle, old_needle_len, offset, 
from_encoding, from_encoding_len ) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|ls, (char 
**)haystack.val, (int *)haystack.len, (char **)needle.val, (int 
*)needle.len, offset, from_encoding, from_encoding_len) == FAILURE) {
RETURN_FALSE;
}
 
-   n = php_mb_stripos(0, old_haystack, old_haystack_len, old_needle, 
old_needle_len, offset, from_encoding TSRMLS_CC);
+   n = php_mb_stripos(0, (char *)haystack.val, haystack.len, (char 
*)needle.val, needle.len, offset, from_encoding TSRMLS_CC);
 
if (n = 0) {
RETVAL_LONG(n);
@@ -2256,21 +2256,21 @@
 {
int n;
long offset;
-   char *old_haystack, *old_needle;
-   char *from_encoding = 
(char*)mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding));
-   int old_haystack_len, old_needle_len, from_encoding_len;
+   mbfl_string haystack, needle;
+   const char *from_encoding = 
mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding));
+   int from_encoding_len;
n = -1;
offset = 0;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|ls, 
old_haystack, old_haystack_len, old_needle, old_needle_len, offset, 
from_encoding, from_encoding_len ) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|ls, (char 
**)haystack.val, (int *)haystack.len, (char **)needle.val, (int 
*)needle.len, offset, from_encoding, from_encoding_len) == FAILURE) {
RETURN_FALSE;
}
 
-   if(offset  old_haystack_len){
+   if (offset  haystack.len) {
RETURN_FALSE;
}
 
-   n = php_mb_stripos(1, old_haystack, old_haystack_len, old_needle, 
old_needle_len, offset, from_encoding TSRMLS_CC);
+   n = php_mb_stripos(1, (char *)haystack.val, haystack.len, (char 
*)needle.val, needle.len, offset, from_encoding TSRMLS_CC);
 
if (n = 0) {
RETVAL_LONG(n);
@@ -2297,7 +2297,7 @@
needle.no_language = MBSTRG(current_language);
needle.no_encoding = MBSTRG(current_internal_encoding);
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|bs, (char 
**)haystack.val, haystack.len, (char **)needle.val, needle.len, part, 
enc_name, enc_name_len) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|bs, (char 
**)haystack.val, (int *)haystack.len, (char **)needle.val, (int 
*)needle.len, part, enc_name, enc_name_len) == FAILURE) {
RETURN_FALSE;
}
 
@@ -2403,9 +2403,9 @@
 PHP_FUNCTION(mb_stristr)
 {
zend_bool part = 0;
-   int n, from_encoding_len, len, mblen;
+   unsigned int n, from_encoding_len, len, mblen;
mbfl_string haystack, needle, result, *ret = NULL;
-   char *from_encoding = 
(char*)mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding));
+   const char *from_encoding = 
mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding));
mbfl_string_init(haystack);
mbfl_string_init(needle);
haystack.no_language = MBSTRG(current_language);
@@ -2418,7 +2418,7 @@
RETURN_FALSE;
}
 
-   if(!needle.len){
+   if (!needle.len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,Empty delimiter.);
RETURN_FALSE;
}
@@ -2429,7 +2429,7 @@
RETURN_FALSE;
}
 
- n = php_mb_stripos(0, haystack.val, haystack.len, needle.val, needle.len, 0, 
from_encoding TSRMLS_CC);
+   n = php_mb_stripos(0, (char *)haystack.val, haystack.len, (char 
*)needle.val, needle.len, 0, 

[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h php_mbregex.c php_mbregex.h

2008-07-17 Thread Moriyoshi Koizumi
moriyoshi   Thu Jul 17 16:08:09 2008 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h php_mbregex.c 
php_mbregex.h 
  Log:
  - Removed dependencies from php_mbregex to oniguruma types
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.c?r1=1.284r2=1.285diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.284 
php-src/ext/mbstring/mbstring.c:1.285
--- php-src/ext/mbstring/mbstring.c:1.284   Wed Jul 16 02:29:14 2008
+++ php-src/ext/mbstring/mbstring.c Thu Jul 17 16:08:08 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.284 2008/07/16 02:29:14 moriyoshi Exp $ */
+/* $Id: mbstring.c,v 1.285 2008/07/17 16:08:08 moriyoshi Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -73,6 +73,10 @@
 
 #include mb_gpc.h
 
+#if HAVE_MBREGEX
+#include php_mbregex.h
+#endif
+
 #ifdef ZEND_MULTIBYTE
 #include zend_multibyte.h
 #endif /* ZEND_MULTIBYTE */
@@ -89,7 +93,7 @@
 /* {{{ php_mb_default_identify_list */
 typedef struct _php_mb_nls_ident_list {
enum mbfl_no_language lang;
-   enum mbfl_no_encoding* list;
+   const enum mbfl_no_encoding* list;
int list_size;
 } php_mb_nls_ident_list;
 
@@ -911,7 +915,7 @@
 
for (i = 0; i  sizeof(php_mb_default_identify_list) / 
sizeof(php_mb_default_identify_list[0]); i++) {
if (php_mb_default_identify_list[i].lang == lang) {
-   *plist = php_mb_default_identify_list[i].list;
+   *plist = (enum mbfl_no_encoding 
*)php_mb_default_identify_list[i].list;
*plist_size = php_mb_default_identify_list[i].list_size;
return 1;
}
@@ -1008,12 +1012,13 @@
MBSTRG(current_internal_encoding) = no_encoding;
 #if HAVE_MBREGEX
{
-   OnigEncoding mbctype;
-   mbctype = php_mb_regex_name2mbctype(new_value);
-   if (mbctype == ONIG_ENCODING_UNDEF) {
-   mbctype = ONIG_ENCODING_EUC_JP;
-   }
-   MBSTRG(current_mbctype) = MBSTRG(default_mbctype) = 
mbctype;
+   const char *enc_name = new_value;
+   if (FAILURE == 
php_mb_regex_set_default_mbctype(enc_name)) {
+   /* falls back to EUC-JP if an unknown encoding 
name is given */
+   enc_name = EUC-JP;
+   php_mb_regex_set_default_mbctype(enc_name);
+   }
+   php_mb_regex_set_mbctype(new_value);
}
 #endif
 #ifdef ZEND_MULTIBYTE
@@ -1164,7 +1169,7 @@
mbstring_globals-strict_detection = 0;
mbstring_globals-outconv = NULL;
 #if HAVE_MBREGEX
-   _php_mb_regex_globals_ctor(mbstring_globals TSRMLS_CC);
+   mbstring_globals-mb_regex_globals = 
php_mb_regex_globals_alloc(TSRMLS_C);
 #endif
 }
 /* }}} */
@@ -1173,7 +1178,7 @@
 static PHP_GSHUTDOWN_FUNCTION(mbstring)
 {
 #if HAVE_MBREGEX
-   _php_mb_regex_globals_dtor(mbstring_globals TSRMLS_CC);
+   php_mb_regex_globals_free(mbstring_globals-mb_regex_globals TSRMLS_CC);
 #endif
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/mbstring.h?r1=1.79r2=1.80diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.79 
php-src/ext/mbstring/mbstring.h:1.80
--- php-src/ext/mbstring/mbstring.h:1.79Wed Jan 30 09:56:21 2008
+++ php-src/ext/mbstring/mbstring.h Thu Jul 17 16:08:08 2008
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: mbstring.h,v 1.79 2008/01/30 09:56:21 dmitry Exp $ */
+/* $Id: mbstring.h,v 1.80 2008/07/17 16:08:08 moriyoshi Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring (currently only for Japanese)
@@ -76,10 +76,6 @@
 
 #define PHP_MBSTRING_API 20021024
 
-#if HAVE_MBREGEX
-#include php_mbregex.h
-#endif
-
 extern zend_module_entry mbstring_module_entry;
 #define mbstring_module_ptr mbstring_module_entry
 
@@ -197,8 +193,8 @@
long strict_detection;
long illegalchars;
mbfl_buffer_converter *outconv;
-#if HAVE_MBREGEX  defined(PHP_MBREGEX_GLOBALS)
-   PHP_MBREGEX_GLOBALS 
+#if HAVE_MBREGEX
+struct _zend_mb_regex_globals *mb_regex_globals;
 #endif
 ZEND_END_MODULE_GLOBALS(mbstring)
 
http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/php_mbregex.c?r1=1.62r2=1.63diff_format=u
Index: php-src/ext/mbstring/php_mbregex.c
diff -u php-src/ext/mbstring/php_mbregex.c:1.62 
php-src/ext/mbstring/php_mbregex.c:1.63
--- php-src/ext/mbstring/php_mbregex.c:1.62 Wed Jul 16 02:29:14 2008
+++ php-src/ext/mbstring/php_mbregex.c  Thu Jul 17 16:08:08 2008
@@ -16,7 +16,7 @@

[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2006-04-03 Thread Seiji Masugata
masugataMon Apr  3 15:32:43 2006 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
  Log:
  added mb_stristr( ), mb_strrichr( ).
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.253r2=1.254diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.253 
php-src/ext/mbstring/mbstring.c:1.254
--- php-src/ext/mbstring/mbstring.c:1.253   Thu Mar 30 15:43:54 2006
+++ php-src/ext/mbstring/mbstring.c Mon Apr  3 15:32:43 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.253 2006/03/30 15:43:54 masugata Exp $ */
+/* $Id: mbstring.c,v 1.254 2006/04/03 15:32:43 masugata Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -177,6 +177,7 @@
{MB_OVERLOAD_STRING, strripos, mb_strripos, mb_orig_stripos},
{MB_OVERLOAD_STRING, strstr, mb_strstr, mb_orig_strstr},
{MB_OVERLOAD_STRING, strrchr, mb_strrchr, mb_orig_strrchr},
+   {MB_OVERLOAD_STRING, stristr, mb_stristr, mb_orig_stristr},
{MB_OVERLOAD_STRING, substr, mb_substr, mb_orig_substr},
{MB_OVERLOAD_STRING, strtolower, mb_strtolower, 
mb_orig_strtolower},
{MB_OVERLOAD_STRING, strtoupper, mb_strtoupper, 
mb_orig_strtoupper},
@@ -213,6 +214,8 @@
PHP_FE(mb_strripos, NULL)
PHP_FE(mb_strstr,   NULL)
PHP_FE(mb_strrchr,  NULL)
+   PHP_FE(mb_stristr,  NULL)
+   PHP_FE(mb_strrichr, NULL)
PHP_FE(mb_substr_count, NULL)
PHP_FE(mb_substr,   NULL)
PHP_FE(mb_strcut,   NULL)
@@ -1859,6 +1862,110 @@
 }
 /* }}} */
 
+/* {{{ proto string mb_stristr(string haystack, string needle[, bool part[, 
string encoding]])
+   Finds first occurrence of a string within another, case insensitive */
+PHP_FUNCTION(mb_stristr)
+{
+   zend_bool part = 0;
+   int n, from_encoding_len, len, mblen;
+   mbfl_string haystack, needle, result, *ret = NULL;
+   char *from_encoding = 
(char*)mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding));
+   mbfl_string_init(haystack);
+   mbfl_string_init(needle);
+   haystack.no_language = MBSTRG(current_language);
+   haystack.no_encoding = MBSTRG(current_internal_encoding);
+   needle.no_language = MBSTRG(current_language);
+   needle.no_encoding = MBSTRG(current_internal_encoding);
+
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|bs, (char 
**)haystack.val, haystack.len, (char **)needle.val, needle.len, part, 
from_encoding, from_encoding_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   haystack.no_encoding = needle.no_encoding = 
mbfl_name2no_encoding(from_encoding);
+   if (haystack.no_encoding == mbfl_no_encoding_invalid) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown encoding 
\%s\, from_encoding);
+   RETURN_FALSE;
+   }
+
+ n = php_mb_stripos(0, haystack.val, haystack.len, needle.val, needle.len, 0, 
from_encoding TSRMLS_CC);
+
+   if (n 0) {
+   RETURN_FALSE;
+   }
+
+   mblen = mbfl_strlen(haystack);
+
+   if (part) {
+   ret = mbfl_substr(haystack, result, 0, n);
+   if (ret != NULL) {
+   RETVAL_STRINGL((char *)ret-val, ret-len, 0);
+   } else {
+   RETVAL_FALSE;
+   }
+   } else {
+   len = (mblen - n);
+   ret = mbfl_substr(haystack, result, n, len);
+   if (ret != NULL) {
+   RETVAL_STRINGL((char *)ret-val, ret-len, 0);
+   } else {
+   RETVAL_FALSE;
+   }
+   }
+}
+
+/* {{{ proto string mb_strrichr(string haystack, string needle[, bool part[, 
string encoding]])
+   Finds the last occurrence of a character in a string within another, case 
insensitive */
+PHP_FUNCTION(mb_strrichr)
+{
+   zend_bool part = 0;
+   int n, from_encoding_len, len, mblen;
+   mbfl_string haystack, needle, result, *ret = NULL;
+   char *from_encoding = 
(char*)mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding));
+   mbfl_string_init(haystack);
+   mbfl_string_init(needle);
+   haystack.no_language = MBSTRG(current_language);
+   haystack.no_encoding = MBSTRG(current_internal_encoding);
+   needle.no_language = MBSTRG(current_language);
+   needle.no_encoding = MBSTRG(current_internal_encoding);
+
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|bs, (char 
**)haystack.val, haystack.len, (char **)needle.val, needle.len, part, 
from_encoding, from_encoding_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   haystack.no_encoding 

[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2006-03-30 Thread Seiji Masugata
masugataThu Mar 30 15:43:54 2006 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
  Log:
  added mb_stripos( ), mb_strripos( ).
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.252r2=1.253diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.252 
php-src/ext/mbstring/mbstring.c:1.253
--- php-src/ext/mbstring/mbstring.c:1.252   Wed Mar 29 15:47:07 2006
+++ php-src/ext/mbstring/mbstring.c Thu Mar 30 15:43:54 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.252 2006/03/29 15:47:07 masugata Exp $ */
+/* $Id: mbstring.c,v 1.253 2006/03/30 15:43:54 masugata Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -173,6 +173,8 @@
{MB_OVERLOAD_STRING, strlen, mb_strlen, mb_orig_strlen},
{MB_OVERLOAD_STRING, strpos, mb_strpos, mb_orig_strpos},
{MB_OVERLOAD_STRING, strrpos, mb_strrpos, mb_orig_strrpos},
+   {MB_OVERLOAD_STRING, stripos, mb_stripos, mb_orig_stripos},
+   {MB_OVERLOAD_STRING, strripos, mb_strripos, mb_orig_stripos},
{MB_OVERLOAD_STRING, strstr, mb_strstr, mb_orig_strstr},
{MB_OVERLOAD_STRING, strrchr, mb_strrchr, mb_orig_strrchr},
{MB_OVERLOAD_STRING, substr, mb_substr, mb_orig_substr},
@@ -207,6 +209,8 @@
PHP_FE(mb_strlen,   NULL)
PHP_FE(mb_strpos,   NULL)
PHP_FE(mb_strrpos,  NULL)
+   PHP_FE(mb_stripos,  NULL)
+   PHP_FE(mb_strripos, NULL)
PHP_FE(mb_strstr,   NULL)
PHP_FE(mb_strrchr,  NULL)
PHP_FE(mb_substr_count, NULL)
@@ -1677,6 +1681,58 @@
 }
 /* }}} */
 
+/* {{{ proto int mb_stripos(string haystack, string needle [, int offset [, 
string encoding]])
+   Finds position of first occurrence of a string within another, case 
insensitive */
+PHP_FUNCTION(mb_stripos)
+{
+   int n;
+   long offset;
+   char *old_haystack, *old_needle;
+   char *from_encoding = 
(char*)mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding));
+   int old_haystack_len, old_needle_len, from_encoding_len;
+   n = -1;
+   offset = 0;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|ls, 
old_haystack, old_haystack_len, old_needle, old_needle_len, offset, 
from_encoding, from_encoding_len ) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+ n = php_mb_stripos(0, old_haystack, old_haystack_len, old_needle, 
old_needle_len, offset, from_encoding TSRMLS_CC);
+
+   if (n = 0) {
+   RETVAL_LONG(n);
+   } else {
+   RETVAL_FALSE;
+   }
+}
+/* }}} */
+
+/* {{{ proto int mb_strripos(string haystack, string needle [, int offset [, 
string encoding]])
+   Finds position of last occurrence of a string within another, case 
insensitive */
+PHP_FUNCTION(mb_strripos)
+{
+   int n;
+   long offset;
+   char *old_haystack, *old_needle;
+   char *from_encoding = 
(char*)mbfl_no2preferred_mime_name(MBSTRG(current_internal_encoding));
+   int old_haystack_len, old_needle_len, from_encoding_len;
+   n = -1;
+   offset = 0;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|ls, 
old_haystack, old_haystack_len, old_needle, old_needle_len, offset, 
from_encoding, from_encoding_len ) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+ n = php_mb_stripos(1, old_haystack, old_haystack_len, old_needle, 
old_needle_len, offset, from_encoding TSRMLS_CC);
+
+   if (n = 0) {
+   RETVAL_LONG(n);
+   } else {
+   RETVAL_FALSE;
+   }
+}
+/* }}} */
+
 /* {{{ proto string mb_strstr(string haystack, string needle[, bool part[, 
string encoding]])
Finds first occurrence of a string within another */
 PHP_FUNCTION(mb_strstr)
@@ -4008,6 +4064,71 @@
 }
 /* }}} */
 
+/* {{{ MBSTRING_API int php_mb_stripos()
+ */
+
+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 TSRMLS_DC)
+{
+   int n;
+   mbfl_string haystack, needle;
+   n = -1;
+
+   mbfl_string_init(haystack);
+   mbfl_string_init(needle);
+   haystack.no_language = MBSTRG(current_language);
+   haystack.no_encoding = MBSTRG(current_internal_encoding);
+   needle.no_language = MBSTRG(current_language);
+   needle.no_encoding = MBSTRG(current_internal_encoding);
+
+   do {
+   haystack.val = php_unicode_convert_case(PHP_UNICODE_CASE_UPPER, 
old_haystack, (size_t) old_haystack_len, haystack.len, from_encoding 
TSRMLS_CC);
+
+   if (!haystack.val) {
+   break;
+   }
+
+   if (haystack.len = 

Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2006-03-30 Thread Derick Rethans
On Thu, 30 Mar 2006, Seiji Masugata wrote:

 masugata  Thu Mar 30 15:43:54 2006 UTC
 
   Modified files:  
 /php-src/ext/mbstring mbstring.c mbstring.h 
   Log:
   added mb_stripos( ), mb_strripos( ).

Just wondering... but why are you adding mb_String functions to HEAD? 
PHP in HEAD has full unicode support which makes the mbstring extension 
obsolete.

regards,
Derick

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2006-03-30 Thread Seiji Masugata
Hi, Derick.

 Just wondering... but why are you adding mb_String functions to HEAD? 
 PHP in HEAD has full unicode support which makes the mbstring extension 
 obsolete.

PHP_5_1 Branch is release process.
If PHP5.1.3 is released, it will be applied to PHP_5_1 Branch.

Can't think that all application can shift to the Unicode at once.


Thank you.

--
Seiji Masugata

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



[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2006-03-29 Thread Seiji Masugata
masugataWed Mar 29 15:47:07 2006 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
  Log:
  added mb_strrchr( ).
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.251r2=1.252diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.251 
php-src/ext/mbstring/mbstring.c:1.252
--- php-src/ext/mbstring/mbstring.c:1.251   Tue Mar 28 16:05:16 2006
+++ php-src/ext/mbstring/mbstring.c Wed Mar 29 15:47:07 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.251 2006/03/28 16:05:16 masugata Exp $ */
+/* $Id: mbstring.c,v 1.252 2006/03/29 15:47:07 masugata Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -174,6 +174,7 @@
{MB_OVERLOAD_STRING, strpos, mb_strpos, mb_orig_strpos},
{MB_OVERLOAD_STRING, strrpos, mb_strrpos, mb_orig_strrpos},
{MB_OVERLOAD_STRING, strstr, mb_strstr, mb_orig_strstr},
+   {MB_OVERLOAD_STRING, strrchr, mb_strrchr, mb_orig_strrchr},
{MB_OVERLOAD_STRING, substr, mb_substr, mb_orig_substr},
{MB_OVERLOAD_STRING, strtolower, mb_strtolower, 
mb_orig_strtolower},
{MB_OVERLOAD_STRING, strtoupper, mb_strtoupper, 
mb_orig_strtoupper},
@@ -207,6 +208,7 @@
PHP_FE(mb_strpos,   NULL)
PHP_FE(mb_strrpos,  NULL)
PHP_FE(mb_strstr,   NULL)
+   PHP_FE(mb_strrchr,  NULL)
PHP_FE(mb_substr_count, NULL)
PHP_FE(mb_substr,   NULL)
PHP_FE(mb_strcut,   NULL)
@@ -1738,6 +1740,69 @@
 }
 /* }}} */
 
+/* {{{ proto string mb_strrchr(string haystack, string needle[, bool part[, 
string encoding]])
+   Finds the last occurrence of a character in a string within another */
+PHP_FUNCTION(mb_strrchr)
+{
+   int n, len, mblen;
+   mbfl_string haystack, needle, result, *ret = NULL;;
+   char *enc_name = NULL;
+   int enc_name_len;
+   zend_bool part = 0;
+
+   mbfl_string_init(haystack);
+   mbfl_string_init(needle);
+   haystack.no_language = MBSTRG(current_language);
+   haystack.no_encoding = MBSTRG(current_internal_encoding);
+   needle.no_language = MBSTRG(current_language);
+   needle.no_encoding = MBSTRG(current_internal_encoding);
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|bs, (char 
**)haystack.val, haystack.len, (char **)needle.val, needle.len, part, 
enc_name, enc_name_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (enc_name != NULL) {
+   haystack.no_encoding = needle.no_encoding = 
mbfl_name2no_encoding(enc_name);
+   if (haystack.no_encoding == mbfl_no_encoding_invalid) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown 
encoding \%s\, enc_name);
+   RETURN_FALSE;
+   }
+   }
+
+   if (haystack.len = 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Empty haystack);
+   RETURN_FALSE;
+   }
+   if (needle.len = 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING,Empty needle);
+   RETURN_FALSE;
+   }
+   n = mbfl_strpos(haystack, needle, 0, 1);
+   if (n = 0) {
+   if (part) {
+   mblen = mbfl_strlen(haystack);
+   ret = mbfl_substr(haystack, result, 0, n);
+   if (ret != NULL) {
+   RETVAL_STRINGL((char *)ret-val, ret-len, 0);
+   } else {
+   RETVAL_FALSE;
+   }
+   } else {
+   mblen = mbfl_strlen(haystack);
+   len = (mblen - n);
+   ret = mbfl_substr(haystack, result, n, len);
+   if (ret != NULL) {
+   RETVAL_STRINGL((char *)ret-val, ret-len, 0);
+   } else {
+   RETVAL_FALSE;
+   }
+   }
+   } else {
+   RETVAL_FALSE;
+   }
+}
+/* }}} */
+
 /* {{{ proto int mb_substr_count(string haystack, string needle [, string 
encoding])
Count the number of substring occurrences */
 PHP_FUNCTION(mb_substr_count)
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.h?r1=1.73r2=1.74diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.73 
php-src/ext/mbstring/mbstring.h:1.74
--- php-src/ext/mbstring/mbstring.h:1.73Tue Mar 28 16:05:16 2006
+++ php-src/ext/mbstring/mbstring.h Wed Mar 29 15:47:07 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: mbstring.h,v 1.73 2006/03/28 

[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2006-03-28 Thread Seiji Masugata
masugataTue Mar 28 16:05:16 2006 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
  Log:
  added mb_strstr( ).
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.250r2=1.251diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.250 
php-src/ext/mbstring/mbstring.c:1.251
--- php-src/ext/mbstring/mbstring.c:1.250   Mon Mar 27 15:20:02 2006
+++ php-src/ext/mbstring/mbstring.c Tue Mar 28 16:05:16 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.250 2006/03/27 15:20:02 masugata Exp $ */
+/* $Id: mbstring.c,v 1.251 2006/03/28 16:05:16 masugata Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -173,6 +173,7 @@
{MB_OVERLOAD_STRING, strlen, mb_strlen, mb_orig_strlen},
{MB_OVERLOAD_STRING, strpos, mb_strpos, mb_orig_strpos},
{MB_OVERLOAD_STRING, strrpos, mb_strrpos, mb_orig_strrpos},
+   {MB_OVERLOAD_STRING, strstr, mb_strstr, mb_orig_strstr},
{MB_OVERLOAD_STRING, substr, mb_substr, mb_orig_substr},
{MB_OVERLOAD_STRING, strtolower, mb_strtolower, 
mb_orig_strtolower},
{MB_OVERLOAD_STRING, strtoupper, mb_strtoupper, 
mb_orig_strtoupper},
@@ -205,6 +206,7 @@
PHP_FE(mb_strlen,   NULL)
PHP_FE(mb_strpos,   NULL)
PHP_FE(mb_strrpos,  NULL)
+   PHP_FE(mb_strstr,   NULL)
PHP_FE(mb_substr_count, NULL)
PHP_FE(mb_substr,   NULL)
PHP_FE(mb_strcut,   NULL)
@@ -1673,6 +1675,69 @@
 }
 /* }}} */
 
+/* {{{ proto string mb_strstr(string haystack, string needle[, bool part[, 
string encoding]])
+   Finds first occurrence of a string within another */
+PHP_FUNCTION(mb_strstr)
+{
+   int n, len, mblen;
+   mbfl_string haystack, needle, result, *ret = NULL;;
+   char *enc_name = NULL;
+   int enc_name_len;
+   zend_bool part = 0;
+
+   mbfl_string_init(haystack);
+   mbfl_string_init(needle);
+   haystack.no_language = MBSTRG(current_language);
+   haystack.no_encoding = MBSTRG(current_internal_encoding);
+   needle.no_language = MBSTRG(current_language);
+   needle.no_encoding = MBSTRG(current_internal_encoding);
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|bs, (char 
**)haystack.val, haystack.len, (char **)needle.val, needle.len, part, 
enc_name, enc_name_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (enc_name != NULL) {
+   haystack.no_encoding = needle.no_encoding = 
mbfl_name2no_encoding(enc_name);
+   if (haystack.no_encoding == mbfl_no_encoding_invalid) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown 
encoding \%s\, enc_name);
+   RETURN_FALSE;
+   }
+   }
+
+   if (haystack.len = 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Empty haystack);
+   RETURN_FALSE;
+   }
+   if (needle.len = 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING,Empty needle);
+   RETURN_FALSE;
+   }
+   n = mbfl_strpos(haystack, needle, 0, 0);
+   if (n = 0) {
+   if (part) {
+   mblen = mbfl_strlen(haystack);
+   ret = mbfl_substr(haystack, result, 0, n);
+   if (ret != NULL) {
+   RETVAL_STRINGL((char *)ret-val, ret-len, 0);
+   } else {
+   RETVAL_FALSE;
+   }
+   } else {
+   mblen = mbfl_strlen(haystack);
+   len = (mblen - n);
+   ret = mbfl_substr(haystack, result, n, len);
+   if (ret != NULL) {
+   RETVAL_STRINGL((char *)ret-val, ret-len, 0);
+   } else {
+   RETVAL_FALSE;
+   }
+   }
+   } else {
+   RETVAL_FALSE;
+   }
+}
+/* }}} */
+
 /* {{{ proto int mb_substr_count(string haystack, string needle [, string 
encoding])
Count the number of substring occurrences */
 PHP_FUNCTION(mb_substr_count)
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.h?r1=1.72r2=1.73diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.72 
php-src/ext/mbstring/mbstring.h:1.73
--- php-src/ext/mbstring/mbstring.h:1.72Mon Mar 27 15:20:02 2006
+++ php-src/ext/mbstring/mbstring.h Tue Mar 28 16:05:16 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: mbstring.h,v 1.72 2006/03/27 15:20:02 masugata Exp $ */
+/* 

[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2006-03-27 Thread Seiji Masugata
masugataMon Mar 27 15:20:02 2006 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
  Log:
  added mb_list_mime_names( ).
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.249r2=1.250diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.249 
php-src/ext/mbstring/mbstring.c:1.250
--- php-src/ext/mbstring/mbstring.c:1.249   Sun Mar 26 02:23:25 2006
+++ php-src/ext/mbstring/mbstring.c Mon Mar 27 15:20:02 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.249 2006/03/26 02:23:25 masugata Exp $ */
+/* $Id: mbstring.c,v 1.250 2006/03/27 15:20:02 masugata Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -214,6 +214,7 @@
PHP_FE(mb_detect_encoding,  NULL)
PHP_FE(mb_list_encodings,   NULL)
PHP_FE(mb_list_encodings_alias_names,   NULL)
+   PHP_FE(mb_list_mime_names,  NULL)
PHP_FE(mb_convert_kana, NULL)
PHP_FE(mb_encode_mimeheader,NULL)
PHP_FE(mb_decode_mimeheader,NULL)
@@ -2425,6 +2426,58 @@
 }
 /* }}} */
 
+/* {{{ proto mixed mb_list_mime_names([string encoding])
+   Returns an array or string of all supported mime names */
+PHP_FUNCTION(mb_list_mime_names)
+{
+   const mbfl_encoding **encodings;
+   const mbfl_encoding *encoding;
+   enum mbfl_no_encoding no_encoding;
+   int i;
+   char *name = NULL;
+   int name_len;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |s, name, 
name_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (name == NULL) {
+   array_init(return_value);
+   i = 0;
+   encodings = mbfl_get_supported_encodings();
+   while ((encoding = encodings[i++]) != NULL) {
+   if(encoding-mime_name != NULL) {
+   add_assoc_string(return_value, (char *) 
encoding-name, (char *) encoding-mime_name, 1);
+   } else{
+   add_assoc_string(return_value, (char *) 
encoding-name, , 1);
+   }
+   }
+   } else {
+   no_encoding = mbfl_name2no_encoding(name);
+   if (no_encoding == mbfl_no_encoding_invalid) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown 
encoding \%s\, name);
+   RETURN_FALSE;
+   }
+
+   name = (char *)mbfl_no_encoding2name(no_encoding);
+   if (name != NULL) {
+   i = 0;
+   encodings = mbfl_get_supported_encodings();
+   while ((encoding = encodings[i++]) != NULL) {
+   if (strcmp(encoding-name, name) != 0){ 
continue; }
+   if(encoding-mime_name != NULL) {
+   RETURN_STRING((char *) 
encoding-mime_name, 1);
+   }
+   break;
+   }
+   RETURN_STRING(, 1);
+   } else {
+   RETURN_FALSE;
+   }
+   }
+}
+/* }}} */
+
 /* {{{ proto string mb_encode_mimeheader(string str [, string charset [, 
string transfer-encoding [, string linefeed [, int indent)
Converts the string to MIME encoded-word in the format of 
=?charset?(B|Q)?encoded_string?= */
 PHP_FUNCTION(mb_encode_mimeheader)
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.h?r1=1.71r2=1.72diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.71 
php-src/ext/mbstring/mbstring.h:1.72
--- php-src/ext/mbstring/mbstring.h:1.71Thu Mar 23 20:14:41 2006
+++ php-src/ext/mbstring/mbstring.h Mon Mar 27 15:20:02 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: mbstring.h,v 1.71 2006/03/23 20:14:41 masugata Exp $ */
+/* $Id: mbstring.h,v 1.72 2006/03/27 15:20:02 masugata Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring (currently only for Japanese)
@@ -113,6 +113,7 @@
 PHP_FUNCTION(mb_detect_encoding);
 PHP_FUNCTION(mb_list_encodings);
 PHP_FUNCTION(mb_list_encodings_alias_names);
+PHP_FUNCTION(mb_list_mime_names);
 PHP_FUNCTION(mb_convert_kana);
 PHP_FUNCTION(mb_encode_mimeheader);
 PHP_FUNCTION(mb_decode_mimeheader);

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



[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h

2006-03-23 Thread Seiji Masugata
masugataThu Mar 23 20:14:41 2006 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
  Log:
  added mb_list_encodings_alias_names( ).
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.247r2=1.248diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.247 
php-src/ext/mbstring/mbstring.c:1.248
--- php-src/ext/mbstring/mbstring.c:1.247   Tue Mar 21 07:47:43 2006
+++ php-src/ext/mbstring/mbstring.c Thu Mar 23 20:14:41 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.247 2006/03/21 07:47:43 hirokawa Exp $ */
+/* $Id: mbstring.c,v 1.248 2006/03/23 20:14:41 masugata Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -213,6 +213,7 @@
PHP_FE(mb_convert_encoding, NULL)
PHP_FE(mb_detect_encoding,  NULL)
PHP_FE(mb_list_encodings,   NULL)
+   PHP_FE(mb_list_encodings_alias_names,   NULL)
PHP_FE(mb_convert_kana, NULL)
PHP_FE(mb_encode_mimeheader,NULL)
PHP_FE(mb_decode_mimeheader,NULL)
@@ -2360,6 +2361,70 @@
 }
 /* }}} */
 
+/* {{{ proto array mb_list_encodings_alias_names([string encoding])
+   Returns an array of all supported alias encodings */
+PHP_FUNCTION(mb_list_encodings_alias_names)
+{
+   const mbfl_encoding **encodings;
+   const mbfl_encoding *encoding;
+   enum mbfl_no_encoding no_encoding;
+   int i, j;
+   zval *row;
+   char *name = NULL;
+   int name_len;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |s, name, 
name_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (name == NULL) {
+   array_init(return_value);
+   i = 0;
+   encodings = mbfl_get_supported_encodings();
+   while ((encoding = encodings[i++]) != NULL) {
+   MAKE_STD_ZVAL(row);
+   array_init(row);
+   if (encoding-aliases != NULL) {
+   j = 0;
+   while ((*encoding-aliases)[j] != NULL) {
+   add_next_index_string(row, (char 
*)(*encoding-aliases)[j], 1);
+   j++;
+   }
+   }
+   add_assoc_zval(return_value, (char *) encoding-name, 
row);
+   }
+   } else {
+   no_encoding = mbfl_name2no_encoding(name);
+   if (no_encoding == mbfl_no_encoding_invalid) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown 
encoding \%s\, name);
+   RETURN_FALSE;
+   }
+
+   name = (char *)mbfl_no_encoding2name(no_encoding);
+   if (name != NULL) {
+   i = 0;
+   encodings = mbfl_get_supported_encodings();
+   while ((encoding = encodings[i++]) != NULL) {
+   if (strcmp(encoding-name, name) != 0){ 
continue; }
+
+   array_init(return_value);
+   if (encoding-aliases != NULL) {
+   j = 0;
+   while ((*encoding-aliases)[j] != NULL) 
{
+   
add_next_index_string(return_value, (char *)(*encoding-aliases)[j], 1);
+   j++;
+   }
+   }
+
+   break;
+   }
+   } else {
+   RETURN_FALSE;
+   }
+   }
+}
+/* }}} */
+
 /* {{{ proto string mb_encode_mimeheader(string str [, string charset [, 
string transfer-encoding [, string linefeed [, int indent)
Converts the string to MIME encoded-word in the format of 
=?charset?(B|Q)?encoded_string?= */
 PHP_FUNCTION(mb_encode_mimeheader)
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.h?r1=1.70r2=1.71diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.70 
php-src/ext/mbstring/mbstring.h:1.71
--- php-src/ext/mbstring/mbstring.h:1.70Tue Mar 21 07:47:43 2006
+++ php-src/ext/mbstring/mbstring.h Thu Mar 23 20:14:41 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: mbstring.h,v 1.70 2006/03/21 07:47:43 hirokawa Exp $ */
+/* $Id: mbstring.h,v 1.71 2006/03/23 20:14:41 masugata Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring (currently only for Japanese)
@@ -112,6 +112,7 @@
 PHP_FUNCTION(mb_convert_encoding);
 PHP_FUNCTION(mb_detect_encoding);
 PHP_FUNCTION(mb_list_encodings);
+PHP_FUNCTION(mb_list_encodings_alias_names);
 

[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /ext/mbstring/libmbfl/mbfl mbfilter.c mbfilter.h mbfl_convert.c mbfl_convert.h

2006-03-20 Thread Rui Hirokawa
hirokawaTue Mar 21 02:11:55 2006 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
/php-src/ext/mbstring/libmbfl/mbfl  mbfilter.c mbfilter.h 
mbfl_convert.c mbfl_convert.h 
  Log:
  MF PHP_5_1
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.244r2=1.245diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.244 
php-src/ext/mbstring/mbstring.c:1.245
--- php-src/ext/mbstring/mbstring.c:1.244   Thu Mar 16 15:21:12 2006
+++ php-src/ext/mbstring/mbstring.c Tue Mar 21 02:11:55 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.244 2006/03/16 15:21:12 masugata Exp $ */
+/* $Id: mbstring.c,v 1.245 2006/03/21 02:11:55 hirokawa Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -786,6 +786,7 @@
MBSTRG(filter_illegal_substchar) = 0x3f;/* '?' */
MBSTRG(current_filter_illegal_mode) = 
MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_substchar) = 0x3f;/* '?' */
+   MBSTRG(illegalchars) = 0;
MBSTRG(func_overload) = 0;
MBSTRG(encoding_translation) = 0;
MBSTRG(strict_detection) = 0;
@@ -928,6 +929,7 @@
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;
 
n = 0;
if (MBSTRG(detect_order_list)) {
@@ -996,6 +998,7 @@
MBSTRG(current_detect_order_list_size) = 0;
}
if (MBSTRG(outconv) != NULL) {
+   MBSTRG(illegalchars) += 
mbfl_buffer_illegalchars(MBSTRG(outconv));
mbfl_buffer_converter_delete(MBSTRG(outconv));
MBSTRG(outconv) = NULL;
}
@@ -1451,6 +1454,7 @@
if ((arg_status  PHP_OUTPUT_HANDLER_START) != 0) {
/* delete the converter just in case. */
if (MBSTRG(outconv)) {
+   MBSTRG(illegalchars) += 
mbfl_buffer_illegalchars(MBSTRG(outconv));
mbfl_buffer_converter_delete(MBSTRG(outconv));
MBSTRG(outconv) = NULL;
}
@@ -1515,6 +1519,7 @@
  
/* delete the converter if it is the last feed. */
if (last_feed) {
+   MBSTRG(illegalchars) += 
mbfl_buffer_illegalchars(MBSTRG(outconv));
mbfl_buffer_converter_delete(MBSTRG(outconv));
MBSTRG(outconv) = NULL;
}
@@ -2079,6 +2084,7 @@
output = (char *)ret-val;
}
 
+   MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv));
mbfl_buffer_converter_delete(convd);
return output;
 }
@@ -2747,6 +2753,7 @@
}
efree(stack);
 
+   MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
}
 
@@ -3439,6 +3446,8 @@
if (lang != NULL  (name = (char 
*)mbfl_no_encoding2name(lang-mail_body_encoding)) != NULL) {
RETVAL_STRING(name, 1);
}
+   } else if (!strcasecmp(illegalchars, typ)) {
+   RETVAL_LONG(MBSTRG(illegalchars));
} else {
RETURN_FALSE;
}
@@ -3605,6 +3614,7 @@
str[i] = ret-val;
len[i] = ret-len;
}
+   MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
}
 
@@ -3821,6 +3831,7 @@
*to = ret-val;
*to_length = ret-len;
}
+   MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
 
return ret ? 0 : -1;
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.h?r1=1.68r2=1.69diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.68 
php-src/ext/mbstring/mbstring.h:1.69
--- php-src/ext/mbstring/mbstring.h:1.68Sun Jan  1 13:09:51 2006
+++ php-src/ext/mbstring/mbstring.h Tue Mar 21 02:11:55 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: mbstring.h,v 1.68 2006/01/01 13:09:51 sniper Exp $ */
+/* $Id: mbstring.h,v 1.69 2006/03/21 02:11:55 hirokawa Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring (currently only for Japanese)
@@ -181,6 +181,7 @@
long func_overload;
zend_bool encoding_translation;
long strict_detection;
+   long illegalchars;
mbfl_buffer_converter *outconv;
 #if HAVE_MBREGEX  defined(PHP_MBREGEX_GLOBALS)
PHP_MBREGEX_GLOBALS 

[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /ext/mbstring/libmbfl/mbfl mbfilter.c

2006-03-20 Thread Rui Hirokawa
hirokawaTue Mar 21 07:47:43 2006 UTC

  Modified files:  
/php-src/ext/mbstring   mbstring.c mbstring.h 
/php-src/ext/mbstring/libmbfl/mbfl  mbfilter.c 
  Log:
  added mb_check_encoding() to detect possible invalid encoding attack.
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.246r2=1.247diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.246 
php-src/ext/mbstring/mbstring.c:1.247
--- php-src/ext/mbstring/mbstring.c:1.246   Tue Mar 21 02:19:59 2006
+++ php-src/ext/mbstring/mbstring.c Tue Mar 21 07:47:43 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: mbstring.c,v 1.246 2006/03/21 02:19:59 hirokawa Exp $ */
+/* $Id: mbstring.c,v 1.247 2006/03/21 07:47:43 hirokawa Exp $ */
 
 /*
  * PHP 4 Multibyte String module mbstring
@@ -221,6 +221,7 @@
PHP_FE(mb_decode_numericentity, NULL)
PHP_FE(mb_send_mail,NULL)
PHP_FE(mb_get_info, NULL)
+   PHP_FE(mb_check_encoding,   NULL)
 #if HAVE_MBREGEX
PHP_MBREGEX_FUNCTION_ENTRIES
 #endif
@@ -2084,7 +2085,7 @@
output = (char *)ret-val;
}
 
-   MBSTRG(illegalchars) += mbfl_buffer_illegalchars(MBSTRG(outconv));
+   MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
return output;
 }
@@ -3454,6 +3455,67 @@
 }
 /* }}} */
 
+/* {{{ proto bool mb_check_encoding([string var[, string encoding]])
+   Check if the string is valid for the specified encoding */
+PHP_FUNCTION(mb_check_encoding)
+{
+   char *var = NULL;
+   int var_len;
+   char *enc = NULL;
+   int enc_len;
+   char *name;
+   mbfl_buffer_converter *convd;
+   enum mbfl_no_encoding no_encoding = MBSTRG(current_internal_encoding);
+   zval *row;
+   mbfl_string string, result, *ret = NULL;
+   long illegalchars = 0;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |ss, var, 
var_len, enc, enc_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (var == NULL) {
+   RETURN_BOOL(MBSTRG(illegalchars) == 0);
+   }
+
+   if (enc != NULL) {
+   no_encoding = mbfl_name2no_encoding(enc);
+   if (no_encoding == mbfl_no_encoding_invalid || no_encoding == 
mbfl_no_encoding_pass) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid 
encoding \%s\, enc);
+   RETURN_FALSE;
+   }
+   }
+   
+   convd = mbfl_buffer_converter_new(no_encoding, no_encoding, 0);
+   if (convd == NULL) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to create 
converter);
+   RETURN_FALSE;
+   }   
+   mbfl_buffer_converter_illegal_mode(convd, 
MBSTRG(current_filter_illegal_mode));
+   mbfl_buffer_converter_illegal_substchar(convd, 
MBSTRG(current_filter_illegal_substchar));   
+   
+   /* initialize string */
+   mbfl_string_init(string);
+   mbfl_string_init(result);
+   string.no_encoding = no_encoding;
+   string.no_language = MBSTRG(current_language);
+
+   string.val = (unsigned char *)var;
+   string.len = var_len;
+   ret = mbfl_buffer_converter_feed_result(convd, string, result);
+   illegalchars = mbfl_buffer_illegalchars(convd);
+   mbfl_buffer_converter_delete(convd);
+
+   if (ret != NULL) {
+   MBSTRG(illegalchars) += illegalchars;
+   efree(ret-val);
+   RETURN_BOOL(illegalchars == 0);
+   } else {
+   RETURN_FALSE;
+   }
+}
+/* }}} */
+
 /* {{{ MBSTRING_API int php_mb_encoding_translation() */
 MBSTRING_API int php_mb_encoding_translation(TSRMLS_D) 
 {
@@ -3614,6 +3676,7 @@
str[i] = ret-val;
len[i] = ret-len;
}
+   
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
}
@@ -3831,6 +3894,7 @@
*to = ret-val;
*to_length = ret-len;
}
+
MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
 
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.h?r1=1.69r2=1.70diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.69 
php-src/ext/mbstring/mbstring.h:1.70
--- php-src/ext/mbstring/mbstring.h:1.69Tue Mar 21 02:11:55 2006
+++ php-src/ext/mbstring/mbstring.h Tue Mar 21 07:47:43 2006
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: mbstring.h,v 1.69 2006/03/21 02:11:55 hirokawa Exp $ */
+/* $Id: mbstring.h,v 1.70 2006/03/21 07:47:43 hirokawa Exp $ */
 
 /*
  * PHP 4 Multibyte String 

Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h/main rfc1867.c

2003-10-26 Thread Moriyoshi Koizumi
Ilia Alshanetsky [EMAIL PROTECTED] wrote:

 On October 25, 2003 07:14 pm, Rasmus Lerdorf wrote:
  Ah, thought it was the other patch.  However, I wouldn't call the above a
  new feature.  That one is a bug fix as it was an oversight to not also
  convert form fields in multipart posts.
 
 Well, it is a mix of a feature  a bug fix. The bug if we decide to call it 
 such is by no means critical and 2 days before the release time is not a time 
 to make any non critical changes simply because there is no time to test 


I kind of agree with Ilia here. It'd be a bad idea to have GPC-related 
patch during the RC period, although the modified parts are all companied 
with #ifdef's as far as I'm concerned.

 them.  rfc1867.c is very sensitive code which previously had a number of 
 security faults at least 1 directly caused by mbstring related changes. It is 
 my opinion such changes have no place this late in the release cycle.

Just want to make it clear, the past problem you mentioned related to 
mbstring is not a security fault, you know.

Moriyoshi

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-26 Thread Rui Hirokawa

Ilia,

I appreciate your continious effort about QC process.
GPC bug in rfc1867.c is not critical one, and I agree with you 
it is not preferable in the final RC process.
I will revert my GPC related patch in a couple of hours.

But, I shoudn't revert an another license related patch 
as shown below because the license compatibility has priority.

+2003-10-25  Rui Hirokawa  [EMAIL PROTECTED]
+
+* (PHP_4_3)
+  ext/mbstring/mbstring.dsp:
+  fixed windows build.
+
+* (PHP_4_3)
+  ext/mbstring/README.libmbfl
+  ext/mbstring/config.m4
+  ext/mbstring/cp932_table.h
+  ext/mbstring/html_entities.c
+  ext/mbstring/mbfilter.c
+  ext/mbstring/mbfilter.h
+  ext/mbstring/mbfilter_cn.c
+  ext/mbstring/mbfilter_cn.h
+  ext/mbstring/mbfilter_ja.c
+  ext/mbstring/mbfilter_ja.h
+  ext/mbstring/mbfilter_kr.c
+  ext/mbstring/mbfilter_kr.h
+  ext/mbstring/mbfilter_ru.c
+  ext/mbstring/mbfilter_ru.h
+  ext/mbstring/mbfilter_tw.c
+  ext/mbstring/mbfilter_tw.h
+  ext/mbstring/mbregex.c
+  ext/mbstring/mbregex.h
+  ext/mbstring/mbstring.c
+  ext/mbstring/mbstring.dsp
+  ext/mbstring/mbstring.h
+  ext/mbstring/unicode_table.h
+  ext/mbstring/unicode_table_cn.h
+  ext/mbstring/unicode_table_ja.h
+  ext/mbstring/unicode_table_kr.h
+  ext/mbstring/unicode_table_ru.h
+  ext/mbstring/unicode_table_tw.h:
+  mbfilter is replaced with libmbfl to maintain the licence compatibility.
+  mbregex.[ch] is moved to mbregex/ for the same reason.
+

On Sun, 26 Oct 2003 00:46:29 -0400
Ilia Alshanetsky [EMAIL PROTECTED] wrote:

 On October 25, 2003 07:14 pm, Rasmus Lerdorf wrote:
  Ah, thought it was the other patch.  However, I wouldn't call the above a
  new feature.  That one is a bug fix as it was an oversight to not also
  convert form fields in multipart posts.
 
 Well, it is a mix of a feature  a bug fix. The bug if we decide to call it 
 such is by no means critical and 2 days before the release time is not a time 
 to make any non critical changes simply because there is no time to test 
 them.  rfc1867.c is very sensitive code which previously had a number of 
 security faults at least 1 directly caused by mbstring related changes. It is 
 my opinion such changes have no place this late in the release cycle.
 
 Ilia


-- 
Rui Hirokawa [EMAIL PROTECTED]

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h/main rfc1867.c

2003-10-26 Thread Moriyoshi Koizumi
Rui, wasn't there any agreement with the author of libmbfl that still 
allows us to keep the modified version in the 4.3 branch? Unless there's 
something obvious, we'd be better off replacing them by the safer stuff
however.

Moriyoshi

Rui Hirokawa [EMAIL PROTECTED] wrote:

 
 Ilia,
 
 I appreciate your continious effort about QC process.
 GPC bug in rfc1867.c is not critical one, and I agree with you 
 it is not preferable in the final RC process.
 I will revert my GPC related patch in a couple of hours.
 
 But, I shoudn't revert an another license related patch 
 as shown below because the license compatibility has priority.

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h/main rfc1867.c

2003-10-26 Thread Rui Hirokawa

Moriyoshi,

Yes, there was a temporary agreement that allows us to release the current version in 
the 4.3 branch until new implementation has stability.

But, I think replacing libmbfl with mbfilter.* in PHP 4.3.4 is preferable because, 
 1. license problem should be solved as quickly as possible.
 2. The differences of libmbfl and the current implementation are 
quite small because the new implementation is based on the current
implementation.
 3. the new implementation with libmbfl is well tested in PHP 5 
since last August.
 4. the new implementation was already confirmed 
to pass the all unit tests in ext/mbstring/tests/*.

Rui

On Sun, 26 Oct 2003 16:31:06 +0900
Moriyoshi Koizumi [EMAIL PROTECTED] wrote:

 Rui, wasn't there any agreement with the author of libmbfl that still 
 allows us to keep the modified version in the 4.3 branch? Unless there's 
 something obvious, we'd be better off replacing them by the safer stuff
 however.
 
 Moriyoshi
 
 Rui Hirokawa [EMAIL PROTECTED] wrote:
 
  
  Ilia,
  
  I appreciate your continious effort about QC process.
  GPC bug in rfc1867.c is not critical one, and I agree with you 
  it is not preferable in the final RC process.
  I will revert my GPC related patch in a couple of hours.
  
  But, I shoudn't revert an another license related patch 
  as shown below because the license compatibility has priority.


-- 
Rui Hirokawa [EMAIL PROTECTED]

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-26 Thread Ilia Alshanetsky
On October 26, 2003 02:20 am, Rui Hirokawa wrote:
 But, I shoudn't revert an another license related patch
 as shown below because the license compatibility has priority.

There is no argument about the license fix patch, it is a necessary evil. I 
will make RC3 on Monday with this patch and if no bugs appear, go forth with 
4.3.4 final 1 week from Monday.

Ilia

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-25 Thread Ilia Alshanetsky
My appologies for the delayed response (I see that the patch was commited). 
After reviewing the patch I would very much prefer if you would revert it and 
wait till PHP 4.3.5 (ot whatever the next release will be) with it.

Ilia

On October 24, 2003 11:08 pm, Rui Hirokawa wrote:
 Yes, I have plan to commit to 4.3 branch.
 Ilia, is it possible to commit ?

 Rui

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-25 Thread Ilia Alshanetsky
On October 25, 2003 06:22 pm, Rasmus Lerdorf wrote:
 And continue breaking licenses knowingly?

That patch does not fix licensing issues, it merely adds a feature, the 
license fix is not there... 

Patch log:
name/value in multipart/form-date will be converted into internal encoding 
when mbstring.encoding_translation is On.

Ilia

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-25 Thread Rasmus Lerdorf
On Sat, 25 Oct 2003, Ilia Alshanetsky wrote:

 On October 25, 2003 06:22 pm, Rasmus Lerdorf wrote:
  And continue breaking licenses knowingly?
 
 That patch does not fix licensing issues, it merely adds a feature, the 
 license fix is not there... 
 
 Patch log:
 name/value in multipart/form-date will be converted into internal encoding 
 when mbstring.encoding_translation is On.

Ah, thought it was the other patch.  However, I wouldn't call the above a
new feature.  That one is a bug fix as it was an oversight to not also
convert form fields in multipart posts.

-Rasmus

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-25 Thread Rui Hirokawa

I think it is a kind of bug fix because,
1. name field of multipart/form was not converted into internal encoding.
   This behavior is different from the usual GPC conversion performed by
mbstr_treat_data() and it might makes confusion for the users.
2. auto-detection might be fail because auto-detection was performed per
   variables. It should be performed using the whole form data as in
mbstr_treat_data().
3. form field was converted into internal encoding even if
mbstring.http_input is set to 'pass'.
4.auto detection was performed even if mbstring.http_input is set to
'pass' or any valid encoding .

And the license fix is an another patch as Rasmus said.

Rui

On Sat, 25 Oct 2003 18:36:41 -0400
Ilia Alshanetsky [EMAIL PROTECTED] wrote:

 On October 25, 2003 06:22 pm, Rasmus Lerdorf wrote:
  And continue breaking licenses knowingly?
 
 That patch does not fix licensing issues, it merely adds a feature, the 
 license fix is not there... 
 
 Patch log:
 name/value in multipart/form-date will be converted into internal encoding 
 when mbstring.encoding_translation is On.
 
 Ilia

-- 
Rui Hirokawa [EMAIL PROTECTED]

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-25 Thread Ilia Alshanetsky
On October 25, 2003 07:14 pm, Rasmus Lerdorf wrote:
 Ah, thought it was the other patch.  However, I wouldn't call the above a
 new feature.  That one is a bug fix as it was an oversight to not also
 convert form fields in multipart posts.

Well, it is a mix of a feature  a bug fix. The bug if we decide to call it 
such is by no means critical and 2 days before the release time is not a time 
to make any non critical changes simply because there is no time to test 
them.  rfc1867.c is very sensitive code which previously had a number of 
security faults at least 1 directly caused by mbstring related changes. It is 
my opinion such changes have no place this late in the release cycle.

Ilia

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



Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-24 Thread Rui Hirokawa

Yes, I have plan to commit to 4.3 branch.
Ilia, is it possible to commit ?

Rui

On Thu, 23 Oct 2003 10:43:16 +0900 (JST)
Rasmus Lerdorf [EMAIL PROTECTED] wrote:

 Are you committing this to 4.3 as well?
 
 On Wed, 22 Oct 2003, Rui Hirokawa wrote:
 
  hirokawaWed Oct 22 10:14:06 2003 EDT
  
Modified files:  
  /php-src/main   rfc1867.c 
  /php-src/ext/mbstring   mbstring.c mbstring.h 
Log:
name/value in multipart/form-date will be converted into internal encoding when 
  mbstring.encoding_translation is On.



-- 
Rui Hirokawa [EMAIL PROTECTED]

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



[PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-22 Thread Rui Hirokawa
hirokawaWed Oct 22 10:14:06 2003 EDT

  Modified files:  
/php-src/main   rfc1867.c 
/php-src/ext/mbstring   mbstring.c mbstring.h 
  Log:
  name/value in multipart/form-date will be converted into internal encoding when 
mbstring.encoding_translation is On.
  Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.141 php-src/main/rfc1867.c:1.142
--- php-src/main/rfc1867.c:1.141Thu Jul  3 11:26:12 2003
+++ php-src/main/rfc1867.c  Wed Oct 22 10:14:04 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: rfc1867.c,v 1.141 2003/07/03 15:26:12 moriyoshi Exp $ */
+/* $Id: rfc1867.c,v 1.142 2003/10/22 14:14:04 hirokawa Exp $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -33,13 +33,15 @@
 #include php_variables.h
 #include rfc1867.h
 
+#undef DEBUG_FILE_UPLOAD
+
 #if HAVE_MBSTRING  !defined(COMPILE_DL_MBSTRING)
 #include ext/mbstring/mbstring.h
-#endif
 
-#undef DEBUG_FILE_UPLOAD
+static void safe_php_register_variable(char *var, char *strval, zval 
*track_vars_array, zend_bool override_protection TSRMLS_DC);
 
 #define SAFE_RETURN { \
+php_mb_flush_gpc_variables(num_vars, val_list, len_list, array_ptr TSRMLS_CC); \
if (lbuf) efree(lbuf); \
if (abuf) efree(abuf); \
if (array_index) efree(array_index); \
@@ -51,6 +53,58 @@
if (mbuff) efree(mbuff); \
return; }
 
+void php_mb_flush_gpc_variables(int num_vars, char **val_list, int *len_list, zval 
*array_ptr  TSRMLS_DC)
+{
+   int i;
+   if (php_mb_encoding_translation(TSRMLS_C)) {
+   if (num_vars  0 
+   php_mb_gpc_encoding_detector(val_list, len_list, num_vars, 
NULL TSRMLS_CC) == SUCCESS) {
+   php_mb_gpc_encoding_converter(val_list, len_list, num_vars, 
NULL, NULL TSRMLS_CC);
+   }
+   for (i=0; inum_vars; i+=2){
+   safe_php_register_variable(val_list[i], val_list[i+1], 
array_ptr, 0 TSRMLS_CC);
+   efree(val_list[i]);
+   efree(val_list[i+1]);
+   } 
+   efree(val_list);
+   efree(len_list);
+   }
+}
+
+void php_mb_gpc_stack_variable(char *param, char *value, char ***pval_list, int 
**plen_list, int *num_vars, int *num_vars_max TSRMLS_DC)
+{
+   char **val_list=*pval_list;
+   int *len_list=*plen_list;
+
+   if (*num_vars=*num_vars_max){
+   (*num_vars_max) += 16;
+   *pval_list = (char **)erealloc(val_list, *num_vars_max*sizeof(char *));
+   *plen_list = (int *)erealloc(len_list, *num_vars_max*sizeof(int));
+   val_list=*pval_list;
+   len_list=*plen_list;
+   }
+   val_list[*num_vars] = (char *)estrdup(param);
+   len_list[*num_vars] = strlen(param);
+   (*num_vars)++;
+   val_list[*num_vars] = (char *)estrdup(value);
+   len_list[*num_vars] = strlen(value);
+   (*num_vars)++;
+}
+
+#else
+
+#define SAFE_RETURN { \
+   if (lbuf) efree(lbuf); \
+   if (abuf) efree(abuf); \
+   if (array_index) efree(array_index); \
+   zend_hash_destroy(PG(rfc1867_protected_variables)); \
+   zend_llist_destroy(header); \
+   if (mbuff-boundary_next) efree(mbuff-boundary_next); \
+   if (mbuff-boundary) efree(mbuff-boundary); \
+   if (mbuff-buffer) efree(mbuff-buffer); \
+   if (mbuff) efree(mbuff); \
+   return; }
+#endif
 
 /* The longest property name we use in an uploaded file array */
 #define MAX_SIZE_OF_INDEX sizeof([tmp_name])
@@ -550,7 +604,8 @@
 
 #if HAVE_MBSTRING  !defined(COMPILE_DL_MBSTRING)
if (php_mb_encoding_translation(TSRMLS_C)) {
-   php_mb_gpc_encoding_detector(str, strlen(str), NULL TSRMLS_CC);
+   int len=strlen(str);
+   php_mb_gpc_encoding_detector(str, len, 1, NULL TSRMLS_CC);
}
 #endif
 
@@ -700,7 +755,8 @@
int max_file_size=0, skip_upload=0, anonindex=0, is_anonymous;
zval *http_post_files=NULL;
 #if HAVE_MBSTRING  !defined(COMPILE_DL_MBSTRING)
-   int str_len = 0;
+   int str_len = 0, num_vars = 0, num_vars_max = 2*10+1, *len_list = NULL;
+   char **val_list = NULL;
 #endif
zend_bool magic_quotes_gpc;
multipart_buffer *mbuff;
@@ -756,6 +812,12 @@
INIT_PZVAL(http_post_files);
PG(http_globals)[TRACK_VARS_FILES] = http_post_files;
 
+#if HAVE_MBSTRING  !defined(COMPILE_DL_MBSTRING)
+   if (php_mb_encoding_translation(TSRMLS_C)) {
+   val_list = (char **)ecalloc(num_vars_max, sizeof(char *));
+   len_list = (int *)ecalloc(num_vars_max, sizeof(int));
+   }
+#endif
zend_llist_init(header, sizeof(mime_header_entry), (llist_dtor_func_t) 
php_free_hdr_entry, 0);
 
while (!multipart_buffer_eof(mbuff TSRMLS_CC))
@@ -818,13 +880,14 @@

Re: [PHP-CVS] cvs: php-src /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

2003-10-22 Thread Rasmus Lerdorf
Are you committing this to 4.3 as well?

On Wed, 22 Oct 2003, Rui Hirokawa wrote:

 hirokawa  Wed Oct 22 10:14:06 2003 EDT
 
   Modified files:  
 /php-src/main rfc1867.c 
 /php-src/ext/mbstring mbstring.c mbstring.h 
   Log:
   name/value in multipart/form-date will be converted into internal encoding when 
 mbstring.encoding_translation is On.
   

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