[PHP-CVS] cvs: php-src /ext/iconv iconv.c
kalle Fri May 15 18:01:05 2009 UTC Modified files: /php-src/ext/iconv iconv.c Log: Fix compiler warnings (only in HEAD), same style of silence as in 5.3 http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.174r2=1.175diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.174 php-src/ext/iconv/iconv.c:1.175 --- php-src/ext/iconv/iconv.c:1.174 Thu Mar 26 20:01:56 2009 +++ php-src/ext/iconv/iconv.c Fri May 15 18:01:05 2009 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.174 2009/03/26 20:01:56 felipe Exp $ */ +/* $Id: iconv.c,v 1.175 2009/05/15 18:01:05 kalle Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -753,15 +753,15 @@ } } - if(len total_len) { + if((unsigned int) len total_len) { len = total_len; } - if (offset = total_len) { + if ((unsigned int) offset = total_len) { return PHP_ICONV_ERR_SUCCESS; } - if ((offset + len) total_len) { + if ((unsigned int) (offset + len) total_len) { /* trying to compute the length */ len = total_len - offset; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Tue Mar 17 05:27:00 2009 UTC Modified files: /php-src/ext/iconv iconv.c Log: - Make iconv filter accept '.' as the delimiter between encoding names as well as '/'. It's impossible to specify the filter in php://filter without this fix. http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.172r2=1.173diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.172 php-src/ext/iconv/iconv.c:1.173 --- php-src/ext/iconv/iconv.c:1.172 Tue Mar 10 23:39:22 2009 +++ php-src/ext/iconv/iconv.c Tue Mar 17 05:27:00 2009 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.172 2009/03/10 23:39:22 helly Exp $ */ +/* $Id: iconv.c,v 1.173 2009/03/17 05:27:00 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2850,7 +2850,7 @@ return NULL; } ++from_charset; - if ((to_charset = strchr(from_charset, '/')) == NULL) { + if ((to_charset = strpbrk(from_charset, /.)) == NULL) { return NULL; } from_charset_len = to_charset - from_charset; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
lbarnaudTue Oct 21 22:05:09 2008 UTC Modified files: /php-src/ext/iconv iconv.c Log: initialize optional vars http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.166r2=1.167diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.166 php-src/ext/iconv/iconv.c:1.167 --- php-src/ext/iconv/iconv.c:1.166 Tue Sep 23 15:22:05 2008 +++ php-src/ext/iconv/iconv.c Tue Oct 21 22:05:09 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.166 2008/09/23 15:22:05 nlopess Exp $ */ +/* $Id: iconv.c,v 1.167 2008/10/21 22:05:09 lbarnaud Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1935,7 +1935,7 @@ Returns the character count of str */ PHP_FUNCTION(iconv_strlen) { - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; zstr str; int str_len, argc = ZEND_NUM_ARGS(); @@ -1945,8 +1945,6 @@ unsigned int retval; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(argc TSRMLS_CC, t|s, str, str_len, str_type, charset, charset_len) == FAILURE) { RETURN_FALSE; @@ -1975,19 +1973,17 @@ Returns specified part of a string */ PHP_FUNCTION(iconv_substr) { - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; zstr str; int str_len; zend_uchar str_type; - long offset, length; + long offset, length = 0; php_iconv_err_t err; smart_str retval = {0}; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, tl|ls, str, str_len, str_type, offset, length, charset, charset_len) == FAILURE) { @@ -2051,7 +2047,7 @@ Finds position of first occurrence of needle within part of haystack beginning with offset */ PHP_FUNCTION(iconv_strpos) { - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; zstr haystk; int haystk_len; @@ -2059,15 +2055,12 @@ zstr ndl; int ndl_len; zend_uchar ndl_type; - long offset; + long offset = 0; php_iconv_err_t err; unsigned int retval; - offset = 0; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, TT|ls, haystk, haystk_len, haystk_type, ndl, ndl_len, ndl_type, offset, charset, charset_len) == FAILURE) { @@ -2118,7 +2111,7 @@ Finds position of last occurrence of needle within part of haystack beginning with offset */ PHP_FUNCTION(iconv_strrpos) { - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; char *haystk; int haystk_len; @@ -2129,8 +2122,6 @@ unsigned int retval; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|s, haystk, haystk_len, ndl, ndl_len, charset, charset_len) == FAILURE) { @@ -2284,7 +2275,7 @@ { char *encoded_str; int encoded_str_len; - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; long mode = 0; @@ -2292,8 +2283,6 @@ php_iconv_err_t err; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|ls, encoded_str, encoded_str_len, mode, charset, charset_len) == FAILURE) { @@ -2327,14 +2316,12 @@ { const char *encoded_str; int encoded_str_len; - char *charset; + char *charset = ICONVG(internal_encoding); int charset_len = 0; long mode = 0; php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS; - charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|ls, encoded_str, encoded_str_len, mode, charset, charset_len) == FAILURE) { @@ -2510,7 +2497,7 @@ PHP_FUNCTION(iconv_get_encoding) { char *type = all; - int type_len; + int type_len = sizeof(all)-1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |s, type, type_len) == FAILURE) return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c /ext/pcre php_pcre.c /ext/standard array.c base64.c image.c versioning.c /main rfc1867.c /main/streams glob_wrapper.c ZendEngine2 zend_constants.c
nlopess Tue Sep 23 15:22:05 2008 UTC Modified files: /ZendEngine2zend_constants.c /php-src/ext/iconv iconv.c /php-src/ext/pcre php_pcre.c /php-src/ext/standard array.c base64.c image.c versioning.c /php-src/main rfc1867.c /php-src/main/streams glob_wrapper.c Log: MFB: clean some dead code http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_constants.c?r1=1.113r2=1.114diff_format=u Index: ZendEngine2/zend_constants.c diff -u ZendEngine2/zend_constants.c:1.113 ZendEngine2/zend_constants.c:1.114 --- ZendEngine2/zend_constants.c:1.113 Tue Aug 12 17:15:59 2008 +++ ZendEngine2/zend_constants.cTue Sep 23 15:22:05 2008 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: zend_constants.c,v 1.113 2008/08/12 17:15:59 felipe Exp $ */ +/* $Id: zend_constants.c,v 1.114 2008/09/23 15:22:05 nlopess Exp $ */ #include zend.h #include zend_constants.h @@ -458,7 +458,6 @@ name = constant_name; name_len = const_name_len; efree(class_name.v); - retval = 1; return zend_u_get_constant(type, name, name_len, result TSRMLS_CC); } if ((flags ZEND_FETCH_CLASS_SILENT) == 0) { http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.165r2=1.166diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.165 php-src/ext/iconv/iconv.c:1.166 --- php-src/ext/iconv/iconv.c:1.165 Wed May 21 15:03:11 2008 +++ php-src/ext/iconv/iconv.c Tue Sep 23 15:22:05 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.165 2008/05/21 15:03:11 tony2001 Exp $ */ +/* $Id: iconv.c,v 1.166 2008/09/23 15:22:05 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1357,7 +1357,6 @@ char_cnt -= 3; } } - prev_in_left = in_left; smart_str_appendl(pretval, ?=, sizeof(?=) - 1); char_cnt -= 2; http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/php_pcre.c?r1=1.240r2=1.241diff_format=u Index: php-src/ext/pcre/php_pcre.c diff -u php-src/ext/pcre/php_pcre.c:1.240 php-src/ext/pcre/php_pcre.c:1.241 --- php-src/ext/pcre/php_pcre.c:1.240 Tue Sep 2 19:13:24 2008 +++ php-src/ext/pcre/php_pcre.c Tue Sep 23 15:22:05 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_pcre.c,v 1.240 2008/09/02 19:13:24 nlopess Exp $ */ +/* $Id: php_pcre.c,v 1.241 2008/09/23 15:22:05 nlopess Exp $ */ /* TODO * php_pcre_replace_impl(): @@ -1023,7 +1023,6 @@ } else { esc_match = ; esc_match_len = 0; - match_len = 0; } smart_str_appendl(code, esc_match, esc_match_len); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.463r2=1.464diff_format=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.463 php-src/ext/standard/array.c:1.464 --- php-src/ext/standard/array.c:1.463 Fri Aug 29 02:48:28 2008 +++ php-src/ext/standard/array.cTue Sep 23 15:22:05 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: array.c,v 1.463 2008/08/29 02:48:28 felipe Exp $ */ +/* $Id: array.c,v 1.464 2008/09/23 15:22:05 nlopess Exp $ */ #include php.h #include php_ini.h @@ -3574,7 +3574,6 @@ } else if (behavior DIFF_ASSOC) { /* triggered also if DIFF_KEY */ /* DIFF_KEY is subset of DIFF_ASSOC. When having the former * no comparison of the data is done (part of DIFF_ASSOC) */ - diff_key_compare_func = php_array_key_compare; if (data_compare_type == DIFF_COMP_DATA_INTERNAL key_compare_type == DIFF_COMP_KEY_INTERNAL) { /* array_diff_assoc() or array_diff_key() */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.55r2=1.56diff_format=u Index: php-src/ext/standard/base64.c diff -u php-src/ext/standard/base64.c:1.55 php-src/ext/standard/base64.c:1.56 --- php-src/ext/standard/base64.c:1.55 Mon Dec 31 07:12:15 2007 +++ php-src/ext/standard/base64.c Tue Sep 23 15:22:05 2008 @@ -15,7 +15,7 @@ | Author: Jim Winstead [EMAIL PROTECTED] | +--+ */ -/* $Id: base64.c,v 1.55
[PHP-CVS] cvs: php-src /ext/iconv iconv.c php_iconv.h
tony2001Wed May 21 15:03:12 2008 UTC Modified files: /php-src/ext/iconv iconv.c php_iconv.h Log: use macros instead of hardcoded encoding names ([EMAIL PROTECTED] AIX is totally broken..) http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.164r2=1.165diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.164 php-src/ext/iconv/iconv.c:1.165 --- php-src/ext/iconv/iconv.c:1.164 Mon Jan 21 07:30:49 2008 +++ php-src/ext/iconv/iconv.c Wed May 21 15:03:11 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.164 2008/01/21 07:30:49 pollita Exp $ */ +/* $Id: iconv.c,v 1.165 2008/05/21 15:03:11 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -225,7 +225,7 @@ /* }}} */ /* {{{ static globals */ -static char _generic_superset_name[] = UCS-4LE; +static char _generic_superset_name[] = ICONV_UCS4_ENCODING; #define GENERIC_SUPERSET_NAME _generic_superset_name #define GENERIC_SUPERSET_NBYTES 4 /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/php_iconv.h?r1=1.36r2=1.37diff_format=u Index: php-src/ext/iconv/php_iconv.h diff -u php-src/ext/iconv/php_iconv.h:1.36 php-src/ext/iconv/php_iconv.h:1.37 --- php-src/ext/iconv/php_iconv.h:1.36 Wed Jan 30 09:56:21 2008 +++ php-src/ext/iconv/php_iconv.h Wed May 21 15:03:11 2008 @@ -17,7 +17,7 @@ +--+ */ -/* $Revision: 1.36 $ */ +/* $Revision: 1.37 $ */ #ifndef PHP_ICONV_H #define PHP_ICONV_H @@ -82,11 +82,13 @@ # define ICONV_OUTPUT_ENCODING ISO8859-1 # define ICONV_INTERNAL_ENCODING ISO8859-1 # define ICONV_ASCII_ENCODING IBM-850 +# define ICONV_UCS4_ENCODING UCS-4 #else # define ICONV_INPUT_ENCODING ISO-8859-1 # define ICONV_OUTPUT_ENCODING ISO-8859-1 # define ICONV_INTERNAL_ENCODING ISO-8859-1 # define ICONV_ASCII_ENCODING ASCII +# define ICONV_UCS4_ENCODING UCS-4LE #endif #ifndef ICONV_CSNMAXLEN -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
pollita Mon Jan 21 07:30:49 2008 UTC Modified files: /php-src/ext/iconv iconv.c Log: Some unicode upgrades... http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.163r2=1.164diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.163 php-src/ext/iconv/iconv.c:1.164 --- php-src/ext/iconv/iconv.c:1.163 Mon Dec 31 07:12:10 2007 +++ php-src/ext/iconv/iconv.c Mon Jan 21 07:30:49 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.163 2007/12/31 07:12:10 sebastian Exp $ */ +/* $Id: iconv.c,v 1.164 2008/01/21 07:30:49 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1932,14 +1932,15 @@ } /* }}} */ -/* {{{ proto int iconv_strlen(string str [, string charset]) +/* {{{ proto int iconv_strlen(string str [, string charset]) U Returns the character count of str */ PHP_FUNCTION(iconv_strlen) { char *charset; int charset_len = 0; - char *str; - int str_len; + zstr str; + int str_len, argc = ZEND_NUM_ARGS(); + zend_uchar str_type; php_iconv_err_t err; @@ -1947,17 +1948,21 @@ charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|s, - str, str_len, charset, charset_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, t|s, + str, str_len, str_type, charset, charset_len) == FAILURE) { RETURN_FALSE; } + if (str_type == IS_UNICODE) { + RETURN_LONG(u_countChar32(str.u, str_len)); + } + if (charset_len = ICONV_CSNMAXLEN) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Charset parameter exceeds the maximum allowed length of %d characters, ICONV_CSNMAXLEN); RETURN_FALSE; } - err = _php_iconv_strlen(retval, str, str_len, charset); + err = _php_iconv_strlen(retval, str.s, str_len, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); if (err == PHP_ICONV_ERR_SUCCESS) { RETVAL_LONG(retval); @@ -1967,14 +1972,15 @@ } /* }}} */ -/* {{{ proto string iconv_substr(string str, int offset, [int length, string charset]) +/* {{{ proto string iconv_substr(string str, int offset, [int length, string charset]) U Returns specified part of a string */ PHP_FUNCTION(iconv_substr) { char *charset; int charset_len = 0; - char *str; + zstr str; int str_len; + zend_uchar str_type; long offset, length; php_iconv_err_t err; @@ -1983,8 +1989,8 @@ charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sl|ls, - str, str_len, offset, length, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, tl|ls, + str, str_len, str_type, offset, length, charset, charset_len) == FAILURE) { RETURN_FALSE; } @@ -1998,10 +2004,38 @@ length = str_len; } - err = _php_iconv_substr(retval, str, str_len, offset, length, charset); + if (str_type == IS_UNICODE) { + int start, end; + + if (offset = 0) { + start = 0; + U16_FWD_N(str.u, start, str_len, offset); + } else { + start = str_len; + U16_BACK_N(str.u, start, str_len, -offset); + } + + if (length 0) { + length += u_countChar32(str.u, str_len); + } + + end = start; + U16_FWD_N(str.u, end, str_len, length); + + if (start str_len) { start = str_len; } + if (endstr_len) { end = str_len; } + + if (end start) { + RETURN_UNICODEL(str.u + start, end - start, ZSTR_DUPLICATE); + } else { + RETURN_EMPTY_UNICODE(); + } + } + + err = _php_iconv_substr(retval, str.s, str_len, offset, length, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); - if (err == PHP_ICONV_ERR_SUCCESS str != NULL) { + if (err == PHP_ICONV_ERR_SUCCESS str.s != NULL) { if (retval.c != NULL) { RETVAL_STRINGL(retval.c, retval.len, 0); } else { @@ -2014,16 +2048,18 @@ } /* }}} */ -/* {{{ proto int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) +/* {{{ proto int iconv_strpos(string haystack, string needle [, int offset [, string charset]]) U Finds position of first occurrence of needle within part of haystack beginning with offset */ PHP_FUNCTION(iconv_strpos) { char *charset; int charset_len = 0; -
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Thu Sep 27 09:18:36 2007 UTC Modified files: /php-src/ext/iconv iconv.c Log: fix coverity issue #412 http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.157r2=1.158diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.157 php-src/ext/iconv/iconv.c:1.158 --- php-src/ext/iconv/iconv.c:1.157 Fri Sep 21 13:41:02 2007 +++ php-src/ext/iconv/iconv.c Thu Sep 27 09:18:36 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.157 2007/09/21 13:41:02 tony2001 Exp $ */ +/* $Id: iconv.c,v 1.158 2007/09/27 09:18:36 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2338,12 +2338,10 @@ } if (header_name != NULL) { - zval **elem; + zval **elem, *new_elem; if (zend_hash_find(Z_ARRVAL_P(return_value), header_name, header_name_len, (void **)elem) == SUCCESS) { if (Z_TYPE_PP(elem) != IS_ARRAY) { - zval *new_elem; - MAKE_STD_ZVAL(new_elem); array_init(new_elem); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Fri Sep 21 13:41:02 2007 UTC Modified files: /php-src/ext/iconv iconv.c Log: plug leak on error (coverity issue #407) http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.156r2=1.157diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.156 php-src/ext/iconv/iconv.c:1.157 --- php-src/ext/iconv/iconv.c:1.156 Thu Sep 20 22:38:25 2007 +++ php-src/ext/iconv/iconv.c Fri Sep 21 13:41:02 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.156 2007/09/20 22:38:25 stas Exp $ */ +/* $Id: iconv.c,v 1.157 2007/09/21 13:41:02 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -913,6 +913,9 @@ cd = iconv_open(GENERIC_SUPERSET_NAME, enc); if (cd == (iconv_t)(-1)) { + if (ndl_buf != NULL) { + efree(ndl_buf); + } #if ICONV_SUPPORTS_ERRNO if (errno == EINVAL) { return PHP_ICONV_ERR_WRONG_CHARSET; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
stasThu Sep 20 21:57:11 2007 UTC Modified files: /php-src/ext/iconv iconv.c Log: MFB length check fix (Mattias Bengtsson) http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.154r2=1.155diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.154 php-src/ext/iconv/iconv.c:1.155 --- php-src/ext/iconv/iconv.c:1.154 Wed Sep 19 00:37:43 2007 +++ php-src/ext/iconv/iconv.c Thu Sep 20 21:57:11 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.154 2007/09/19 00:37:43 stas Exp $ */ +/* $Id: iconv.c,v 1.155 2007/09/20 21:57:11 stas Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -765,7 +765,7 @@ } } - if (offset = total_len) { + if (offset = total_len || len total_len) { return PHP_ICONV_ERR_SUCCESS; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
stasThu Sep 20 22:38:25 2007 UTC Modified files: /php-src/ext/iconv iconv.c Log: better fix for iconv_substr http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.155r2=1.156diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.155 php-src/ext/iconv/iconv.c:1.156 --- php-src/ext/iconv/iconv.c:1.155 Thu Sep 20 21:57:11 2007 +++ php-src/ext/iconv/iconv.c Thu Sep 20 22:38:25 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.155 2007/09/20 21:57:11 stas Exp $ */ +/* $Id: iconv.c,v 1.156 2007/09/20 22:38:25 stas Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -765,10 +765,14 @@ } } - if (offset = total_len || len total_len) { + if(len total_len) { + len = total_len; + } + + if (offset = total_len) { return PHP_ICONV_ERR_SUCCESS; } - + if ((offset + len) total_len) { /* trying to compute the length */ len = total_len - offset; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c php_iconv.h
stasWed Sep 19 00:37:43 2007 UTC Modified files: /php-src/ext/iconv iconv.c php_iconv.h Log: limit iconv parameter sizes - workaround for libc bug http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.153r2=1.154diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.153 php-src/ext/iconv/iconv.c:1.154 --- php-src/ext/iconv/iconv.c:1.153 Mon May 28 23:52:13 2007 +++ php-src/ext/iconv/iconv.c Wed Sep 19 00:37:43 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.153 2007/05/28 23:52:13 iliaa Exp $ */ +/* $Id: iconv.c,v 1.154 2007/09/19 00:37:43 stas Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -230,12 +230,21 @@ #define GENERIC_SUPERSET_NBYTES 4 /* }}} */ +static PHP_INI_MH(OnUpdateStringIconvCharset) +{ + if(new_value_length = ICONV_CSNMAXLEN) { + return FAILURE; + } + OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + return SUCCESS; +} + /* {{{ PHP_INI */ PHP_INI_BEGIN() - STD_PHP_INI_ENTRY(iconv.input_encoding,ICONV_INPUT_ENCODING, PHP_INI_ALL, OnUpdateString, input_encoding,zend_iconv_globals, iconv_globals) - STD_PHP_INI_ENTRY(iconv.output_encoding, ICONV_OUTPUT_ENCODING, PHP_INI_ALL, OnUpdateString, output_encoding, zend_iconv_globals, iconv_globals) - STD_PHP_INI_ENTRY(iconv.internal_encoding, ICONV_INTERNAL_ENCODING, PHP_INI_ALL, OnUpdateString, internal_encoding, zend_iconv_globals, iconv_globals) + STD_PHP_INI_ENTRY(iconv.input_encoding,ICONV_INPUT_ENCODING, PHP_INI_ALL, OnUpdateStringIconvCharset, input_encoding,zend_iconv_globals, iconv_globals) + STD_PHP_INI_ENTRY(iconv.output_encoding, ICONV_OUTPUT_ENCODING, PHP_INI_ALL, OnUpdateStringIconvCharset, output_encoding, zend_iconv_globals, iconv_globals) + STD_PHP_INI_ENTRY(iconv.internal_encoding, ICONV_INTERNAL_ENCODING, PHP_INI_ALL, OnUpdateStringIconvCharset, internal_encoding, zend_iconv_globals, iconv_globals) PHP_INI_END() /* }}} */ @@ -1921,7 +1930,7 @@ PHP_FUNCTION(iconv_strlen) { char *charset; - int charset_len; + int charset_len = 0; char *str; int str_len; @@ -1936,6 +1945,11 @@ RETURN_FALSE; } + if (charset_len = ICONV_CSNMAXLEN) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Charset parameter exceeds the maximum allowed length of %d characters, ICONV_CSNMAXLEN); + RETURN_FALSE; + } + err = _php_iconv_strlen(retval, str, str_len, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); if (err == PHP_ICONV_ERR_SUCCESS) { @@ -1951,7 +1965,7 @@ PHP_FUNCTION(iconv_substr) { char *charset; - int charset_len; + int charset_len = 0; char *str; int str_len; long offset, length; @@ -1968,6 +1982,11 @@ RETURN_FALSE; } + if (charset_len = ICONV_CSNMAXLEN) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Charset parameter exceeds the maximum allowed length of %d characters, ICONV_CSNMAXLEN); + RETURN_FALSE; + } + if (ZEND_NUM_ARGS() 3) { length = str_len; } @@ -1993,7 +2012,7 @@ PHP_FUNCTION(iconv_strpos) { char *charset; - int charset_len; + int charset_len = 0; char *haystk; int haystk_len; char *ndl; @@ -2013,6 +2032,11 @@ RETURN_FALSE; } + if (charset_len = ICONV_CSNMAXLEN) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Charset parameter exceeds the maximum allowed length of %d characters, ICONV_CSNMAXLEN); + RETURN_FALSE; + } + if (offset 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Offset not contained in string); RETURN_FALSE; @@ -2039,7 +2063,7 @@ PHP_FUNCTION(iconv_strrpos) { char *charset; - int charset_len; + int charset_len = 0; char *haystk; int haystk_len; char *ndl; @@ -2061,6 +2085,11 @@ RETURN_FALSE; } + if (charset_len = ICONV_CSNMAXLEN) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Charset parameter exceeds the maximum allowed length of %d characters, ICONV_CSNMAXLEN); + RETURN_FALSE; + } + err = _php_iconv_strpos(retval, haystk, haystk_len, ndl, ndl_len, -1, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); @@ -2117,6 +2146,11 @@ } if (zend_hash_find(Z_ARRVAL_P(pref), input-charset, sizeof(input-charset), (void **)ppval) == SUCCESS) { + if (Z_STRLEN_PP(ppval) =
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Wed Jan 24 00:33:44 2007 UTC Modified files: /php-src/ext/iconv iconv.c Log: initialize errno http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.151r2=1.152diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.151 php-src/ext/iconv/iconv.c:1.152 --- php-src/ext/iconv/iconv.c:1.151 Wed Jan 17 20:31:49 2007 +++ php-src/ext/iconv/iconv.c Wed Jan 24 00:33:44 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.151 2007/01/17 20:31:49 tony2001 Exp $ */ +/* $Id: iconv.c,v 1.152 2007/01/24 00:33:44 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -784,6 +784,7 @@ } cd2 = (iconv_t)NULL; + errno = 0; for (in_p = str, in_left = nbytes, cnt = 0; in_left 0 len 0; ++cnt) { size_t prev_in_left; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Wed Jan 17 20:31:49 2007 UTC Modified files: /php-src/ext/iconv iconv.c Log: fix #40129 (iconv extension doesn't compile with CodeWarrior on Netware) patch by gk at gknw dot de http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.150r2=1.151diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.150 php-src/ext/iconv/iconv.c:1.151 --- php-src/ext/iconv/iconv.c:1.150 Mon Jan 1 09:29:24 2007 +++ php-src/ext/iconv/iconv.c Wed Jan 17 20:31:49 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.150 2007/01/01 09:29:24 sebastian Exp $ */ +/* $Id: iconv.c,v 1.151 2007/01/17 20:31:49 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -255,12 +255,16 @@ } #elif HAVE_GLIBC_ICONV version = (char *)gnu_get_libc_version(); +#elif defined(NETWARE) + version = OS built-in; #endif #ifdef PHP_ICONV_IMPL REGISTER_STRING_CONSTANT(ICONV_IMPL, PHP_ICONV_IMPL, CONST_CS | CONST_PERSISTENT); #elif HAVE_LIBICONV REGISTER_STRING_CONSTANT(ICONV_IMPL, libiconv, CONST_CS | CONST_PERSISTENT); +#elif defined(NETWARE) + REGISTER_STRING_CONSTANT(ICONV_IMPL, Novell, CONST_CS | CONST_PERSISTENT); #else REGISTER_STRING_CONSTANT(ICONV_IMPL, unknown, CONST_CS | CONST_PERSISTENT); #endif @@ -499,7 +503,11 @@ out_buffer = (char *) emalloc(out_size + 1); out_p = out_buffer; +#ifdef NETWARE + result = iconv(cd, (char **) in_p, in_size, (char **) +#else result = iconv(cd, (const char **) in_p, in_size, (char **) +#endif out_p, out_left); if (result == (size_t)(-1)) { @@ -775,7 +783,7 @@ #endif } - cd2 = NULL; + cd2 = (iconv_t)NULL; for (in_p = str, in_left = nbytes, cnt = 0; in_left 0 len 0; ++cnt) { size_t prev_in_left; @@ -791,11 +799,11 @@ } if (cnt = (unsigned int)offset) { - if (cd2 == NULL) { + if (cd2 == (iconv_t)NULL) { cd2 = iconv_open(enc, GENERIC_SUPERSET_NAME); if (cd2 == (iconv_t)(-1)) { - cd2 = NULL; + cd2 = (iconv_t)NULL; #if ICONV_SUPPORTS_ERRNO if (errno == EINVAL) { err = PHP_ICONV_ERR_WRONG_CHARSET; @@ -832,17 +840,17 @@ } #endif if (err == PHP_ICONV_ERR_SUCCESS) { - if (cd2 != NULL) { + if (cd2 != (iconv_t)NULL) { _php_iconv_appendl(pretval, NULL, 0, cd2); } smart_str_0(pretval); } - if (cd1 != NULL) { + if (cd1 != (iconv_t)NULL) { iconv_close(cd1); } - if (cd2 != NULL) { + if (cd2 != (iconv_t)NULL) { iconv_close(cd2); } return err; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Mon Dec 25 20:44:28 2006 UTC Modified files: /php-src/ext/iconv iconv.c Log: use safe_emalloc() http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.148r2=1.149diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.148 php-src/ext/iconv/iconv.c:1.149 --- php-src/ext/iconv/iconv.c:1.148 Wed Dec 20 10:38:24 2006 +++ php-src/ext/iconv/iconv.c Mon Dec 25 20:44:28 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.148 2006/12/20 10:38:24 bjori Exp $ */ +/* $Id: iconv.c,v 1.149 2006/12/25 20:44:28 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1105,7 +1105,7 @@ goto out; } - buf = emalloc(max_line_len + 5); + buf = safe_emalloc(1, max_line_len, 5); char_cnt = max_line_len; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c /ext/standard basic_functions.c /main php.h ZendEngine2 zend_API.h
bjori Wed Dec 20 10:38:25 2006 UTC Modified files: /ZendEngine2zend_API.h /php-src/main php.h /php-src/ext/standard basic_functions.c /php-src/ext/iconv iconv.c Log: MFB: - Fixed incorrect function names on FreeBSD where inet_pton() was named __inet_pton() and inet_ntop() was named __inet_ntop() - Fixed bug #39685 (iconv() - undefined function) - Fixed bug #38852 (XML-RPC Breaks iconv) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.h?r1=1.275r2=1.276diff_format=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.275 ZendEngine2/zend_API.h:1.276 --- ZendEngine2/zend_API.h:1.275Tue Dec 19 21:38:59 2006 +++ ZendEngine2/zend_API.h Wed Dec 20 10:38:24 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: zend_API.h,v 1.275 2006/12/19 21:38:59 andrei Exp $ */ +/* $Id: zend_API.h,v 1.276 2006/12/20 10:38:24 bjori Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -48,6 +48,9 @@ #define ZEND_FENTRY(zend_name, name, arg_info, flags) { #zend_name, name, arg_info, (zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags }, +#define ZEND_RAW_FENTRY(zend_name, name, arg_info, flags) { zend_name, name, arg_info, (zend_uint) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags }, +#define ZEND_RAW_NAMED_FE(zend_name, name, arg_info) ZEND_RAW_FENTRY(#zend_name, name, arg_info, 0) + #define ZEND_NAMED_FE(zend_name, name, arg_info) ZEND_FENTRY(zend_name, name, arg_info, 0) #define ZEND_FE(name, arg_info) ZEND_FENTRY(name, ZEND_FN(name), arg_info, 0) #define ZEND_DEP_FE(name, arg_info) ZEND_FENTRY(name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED) http://cvs.php.net/viewvc.cgi/php-src/main/php.h?r1=1.235r2=1.236diff_format=u Index: php-src/main/php.h diff -u php-src/main/php.h:1.235 php-src/main/php.h:1.236 --- php-src/main/php.h:1.235Fri Nov 17 11:41:13 2006 +++ php-src/main/php.h Wed Dec 20 10:38:24 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: php.h,v 1.235 2006/11/17 11:41:13 dmitry Exp $ */ +/* $Id: php.h,v 1.236 2006/12/20 10:38:24 bjori Exp $ */ #ifndef PHP_H #define PHP_H @@ -336,6 +336,7 @@ #define PHP_FUNCTION ZEND_FUNCTION #define PHP_METHOD ZEND_METHOD +#define PHP_RAW_NAMED_FE ZEND_RAW_NAMED_FE #define PHP_NAMED_FE ZEND_NAMED_FE #define PHP_FE ZEND_FE #define PHP_DEP_FE ZEND_DEP_FE http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.841r2=1.842diff_format=u Index: php-src/ext/standard/basic_functions.c diff -u php-src/ext/standard/basic_functions.c:1.841 php-src/ext/standard/basic_functions.c:1.842 --- php-src/ext/standard/basic_functions.c:1.841Tue Dec 19 22:01:50 2006 +++ php-src/ext/standard/basic_functions.c Wed Dec 20 10:38:24 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: basic_functions.c,v 1.841 2006/12/19 22:01:50 andrei Exp $ */ +/* $Id: basic_functions.c,v 1.842 2006/12/20 10:38:24 bjori Exp $ */ #include php.h #include php_streams.h @@ -3378,10 +3378,10 @@ PHP_FE(number_format, arginfo_number_format) PHP_FE(fmod, arginfo_fmod) #ifdef HAVE_INET_NTOP - PHP_NAMED_FE(inet_ntop, php_inet_ntop, arginfo_inet_ntop) + PHP_RAW_NAMED_FE(inet_ntop, php_inet_ntop, arginfo_inet_ntop) #endif #ifdef HAVE_INET_PTON - PHP_NAMED_FE(inet_pton, php_inet_pton, arginfo_inet_pton) + PHP_RAW_NAMED_FE(inet_pton, php_inet_pton, arginfo_inet_pton) #endif PHP_FE(ip2long, arginfo_ip2long) PHP_FE(long2ip, arginfo_long2ip) http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.147r2=1.148diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.147 php-src/ext/iconv/iconv.c:1.148 --- php-src/ext/iconv/iconv.c:1.147 Wed Nov 15 18:35:18 2006 +++ php-src/ext/iconv/iconv.c Wed Dec 20 10:38:24 2006 @@ -18,7 +18,7 @@ +--+ */
[PHP-CVS] cvs: php-src /ext/iconv iconv.c /ext/iconv/tests bug37773.phpt
iliaa Wed Nov 15 18:35:18 2006 UTC Modified files: /php-src/ext/iconv iconv.c /php-src/ext/iconv/testsbug37773.phpt Log: MFB: Fixed bug #37773 (iconv_substr() gives Unknown error when string length = 1). http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.146r2=1.147diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.146 php-src/ext/iconv/iconv.c:1.147 --- php-src/ext/iconv/iconv.c:1.146 Sun Oct 8 13:34:22 2006 +++ php-src/ext/iconv/iconv.c Wed Nov 15 18:35:18 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.146 2006/10/08 13:34:22 bjori Exp $ */ +/* $Id: iconv.c,v 1.147 2006/11/15 18:35:18 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -809,7 +809,9 @@ } } - _php_iconv_appendl(pretval, buf, sizeof(buf), cd2); + if (_php_iconv_appendl(pretval, buf, sizeof(buf), cd2) != PHP_ICONV_ERR_SUCCESS) { + break; + } --len; } @@ -827,10 +829,6 @@ case E2BIG: break; - - default: - err = PHP_ICONV_ERR_UNKNOWN; - break; } #endif if (err == PHP_ICONV_ERR_SUCCESS) { http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/bug37773.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/iconv/tests/bug37773.phpt diff -u /dev/null php-src/ext/iconv/tests/bug37773.phpt:1.2 --- /dev/null Wed Nov 15 18:35:18 2006 +++ php-src/ext/iconv/tests/bug37773.phpt Wed Nov 15 18:35:18 2006 @@ -0,0 +1,10 @@ +--TEST-- +Bug #37773 (iconv_substr() gives Unknown error when string length = 1) +--SKIPIF-- +?php include('skipif.inc'); ? +--FILE-- +?php + var_dump(iconv_substr('x', 0, 1, 'UTF-8')); +? +--EXPECT-- +string(1) x \ No newline at end of file -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Tue Sep 12 17:26:24 2006 UTC Modified files: /php-src/ext/iconv iconv.c Log: improve spelling (fixes #38780) http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.144r2=1.145diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.144 php-src/ext/iconv/iconv.c:1.145 --- php-src/ext/iconv/iconv.c:1.144 Sat Sep 9 12:10:28 2006 +++ php-src/ext/iconv/iconv.c Tue Sep 12 17:26:24 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.144 2006/09/09 12:10:28 mike Exp $ */ +/* $Id: iconv.c,v 1.145 2006/09/12 17:26:24 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1894,7 +1894,7 @@ case PHP_ICONV_ERR_TOO_BIG: /* should not happen */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, Run out of buffer); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Buffer length exceeded); break; case PHP_ICONV_ERR_MALFORMED: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
mikeSat Sep 9 12:10:29 2006 UTC Modified files: /php-src/ext/iconv iconv.c Log: - fix crash when unicode.sematics are enabled and unicode.output_encoding doesn't match iconv.internal_encoding http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.143r2=1.144diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.143 php-src/ext/iconv/iconv.c:1.144 --- php-src/ext/iconv/iconv.c:1.143 Thu Sep 7 14:21:02 2006 +++ php-src/ext/iconv/iconv.c Sat Sep 9 12:10:28 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.143 2006/09/07 14:21:02 mike Exp $ */ +/* $Id: iconv.c,v 1.144 2006/09/09 12:10:28 mike Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -343,8 +343,7 @@ output_encoding = INI_STR(unicode.output_encoding); if (output_encoding *output_encoding ucnv_compareNames(output_encoding, ICONVG(internal_encoding))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, unicode.output_encoding differs from iconv.internal_encoding (%s, %s), output_encoding, ICONVG(internal_encoding)); - efree(ICONVG(input_encoding)); - ICONVG(input_encoding) = estrdup(output_encoding); + zend_alter_ini_entry(ZEND_STRS(iconv.internal_encoding), output_encoding, strlen(output_encoding), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
mikeThu Sep 7 14:20:16 2006 UTC Modified files: /php-src/ext/iconv iconv.c Log: - use ucnv_compareNames - check output_context-op for PHP_OUTPUT_HANDLER_CLEAN instead of php_output_get_status() http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.141r2=1.142diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.141 php-src/ext/iconv/iconv.c:1.142 --- php-src/ext/iconv/iconv.c:1.141 Wed Sep 6 20:49:03 2006 +++ php-src/ext/iconv/iconv.c Thu Sep 7 14:20:16 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.141 2006/09/06 20:49:03 mike Exp $ */ +/* $Id: iconv.c,v 1.142 2006/09/07 14:20:16 mike Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -341,7 +341,7 @@ if (UG(unicode)) { output_encoding = INI_STR(unicode.output_encoding); - if (output_encoding *output_encoding strcasecmp(INI_STR(unicode.output_encoding), ICONVG(internal_encoding))) { + if (output_encoding *output_encoding ucnv_compareNames(output_encoding, ICONVG(internal_encoding))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, unicode.output_encoding differs from iconv.internal_encoding (%s, %s), output_encoding, ICONVG(internal_encoding)); efree(ICONVG(input_encoding)); ICONVG(input_encoding) = estrdup(output_encoding); @@ -359,7 +359,7 @@ mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE; } - if (mimetype != NULL !(output_status PHP_OUTPUT_HANDLER_CLEAN)) { + if (mimetype != NULL !(output_context-op PHP_OUTPUT_HANDLER_CLEAN)) { spprintf(content_type, 0, Content-Type: %.*s; charset=%s, mimetype_len?mimetype_len:strlen(mimetype), mimetype, ICONVG(output_encoding)); if (content_type SUCCESS == sapi_add_header(content_type, strlen(content_type), 0)) { SG(sapi_headers).send_default_content_type = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
mikeThu Sep 7 14:21:02 2006 UTC Modified files: /php-src/ext/iconv iconv.c Log: -fix warnings http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.142r2=1.143diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.142 php-src/ext/iconv/iconv.c:1.143 --- php-src/ext/iconv/iconv.c:1.142 Thu Sep 7 14:20:16 2006 +++ php-src/ext/iconv/iconv.c Thu Sep 7 14:21:02 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.142 2006/09/07 14:20:16 mike Exp $ */ +/* $Id: iconv.c,v 1.143 2006/09/07 14:21:02 mike Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1225,7 +1225,7 @@ prev_in_left = in_left; - encoded = php_base64_encode(buf, (int)(out_size - out_left), dummy); + encoded = (char *) php_base64_encode((unsigned char *) buf, (int)(out_size - out_left), dummy); encoded_len = (size_t)dummy; if (char_cnt encoded_len) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c /ext/iconv/tests iconv_strpos.phpt iconv_strrpos.phpt
tony2001Wed Sep 6 12:07:27 2006 UTC Modified files: /php-src/ext/iconv iconv.c /php-src/ext/iconv/testsiconv_strpos.phpt iconv_strrpos.phpt Log: do not search for empty strings with strpos() and strrpos() http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.139r2=1.140diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.139 php-src/ext/iconv/iconv.c:1.140 --- php-src/ext/iconv/iconv.c:1.139 Thu Aug 31 11:17:37 2006 +++ php-src/ext/iconv/iconv.c Wed Sep 6 12:07:27 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.139 2006/08/31 11:17:37 tony2001 Exp $ */ +/* $Id: iconv.c,v 1.140 2006/09/06 12:07:27 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1949,6 +1949,10 @@ RETURN_FALSE; } + if (ndl_len 1) { + RETURN_FALSE; + } + err = _php_iconv_strpos(retval, haystk, haystk_len, ndl, ndl_len, offset, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); @@ -1984,6 +1988,10 @@ RETURN_FALSE; } + if (ndl_len 1) { + RETURN_FALSE; + } + err = _php_iconv_strpos(retval, haystk, haystk_len, ndl, ndl_len, -1, charset); _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC); http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strpos.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/iconv/tests/iconv_strpos.phpt diff -u php-src/ext/iconv/tests/iconv_strpos.phpt:1.2 php-src/ext/iconv/tests/iconv_strpos.phpt:1.3 --- php-src/ext/iconv/tests/iconv_strpos.phpt:1.2 Wed Aug 17 14:01:03 2005 +++ php-src/ext/iconv/tests/iconv_strpos.phpt Wed Sep 6 12:07:27 2006 @@ -33,6 +33,9 @@ foo(str_repeat(¤¢¤¤¤¦¤¨¤ª, 30).¤¤¤¦¤ª¤¨¤¢.str_repeat(¤¢¤¤¤¨¤ª¤¦, 30), ¤¦¤ª, 0, EUC-JP); $str = str_repeat(¤¢¤¤¤¦¤¨¤ª, 60).'$'.str_repeat(¤¢¤¤¤¨¤ª¤¦, 60); foo($str, '$', 0, ISO-2022-JP, EUC-JP); + +var_dump(iconv_strpos(string, )); +var_dump(iconv_strpos(, string)); ? --EXPECTF-- 2: %s @@ -52,3 +55,5 @@ int(151) int(1) int(300) +bool(false) +bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/tests/iconv_strrpos.phpt?r1=1.2r2=1.3diff_format=u Index: php-src/ext/iconv/tests/iconv_strrpos.phpt diff -u php-src/ext/iconv/tests/iconv_strrpos.phpt:1.2 php-src/ext/iconv/tests/iconv_strrpos.phpt:1.3 --- php-src/ext/iconv/tests/iconv_strrpos.phpt:1.2 Wed Aug 17 14:01:03 2005 +++ php-src/ext/iconv/tests/iconv_strrpos.phpt Wed Sep 6 12:07:27 2006 @@ -34,6 +34,9 @@ $str = str_repeat(¤¢¤¤¤¦¤¨¤ª, 60).str_repeat('$', $i).str_repeat(¤¢¤¤¤¨¤ª¤¦, 60); foo($str, '$', ISO-2022-JP, EUC-JP); } + +var_dump(iconv_strrpos(string, )); +var_dump(iconv_strrpos(, string)); ? --EXPECT-- int(14) @@ -56,3 +59,5 @@ int(304) int(606) int(305) +bool(false) +bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Thu Aug 31 11:17:37 2006 UTC Modified files: /php-src/ext/iconv iconv.c Log: minor changes in iconv_substr() to avoid zval converting http://cvs.php.net/viewvc.cgi/php-src/ext/iconv/iconv.c?r1=1.138r2=1.139diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.138 php-src/ext/iconv/iconv.c:1.139 --- php-src/ext/iconv/iconv.c:1.138 Wed Aug 30 16:12:27 2006 +++ php-src/ext/iconv/iconv.c Thu Aug 31 11:17:37 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.138 2006/08/30 16:12:27 tony2001 Exp $ */ +/* $Id: iconv.c,v 1.139 2006/08/31 11:17:37 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1886,7 +1886,6 @@ char *str; int str_len; long offset, length; - zval *len_z = NULL; php_iconv_err_t err; @@ -1894,17 +1893,14 @@ charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sl|zs, - str, str_len, offset, len_z, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sl|ls, + str, str_len, offset, length, charset, charset_len) == FAILURE) { RETURN_FALSE; } - if (len_z == NULL) { + if (ZEND_NUM_ARGS() 3) { length = str_len; - } else { - convert_to_long_ex(len_z); - length = Z_LVAL_P(len_z); } err = _php_iconv_substr(retval, str, str_len, offset, length, charset); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
andrei Tue Jun 13 15:57:46 2006 UTC Modified files: /php-src/ext/iconv iconv.c Log: Move GINIT definition above re-definition of iconv. Gah. http://cvs.php.net/viewcvs.cgi/php-src/ext/iconv/iconv.c?r1=1.135r2=1.136diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.135 php-src/ext/iconv/iconv.c:1.136 --- php-src/ext/iconv/iconv.c:1.135 Tue Jun 13 13:12:18 2006 +++ php-src/ext/iconv/iconv.c Tue Jun 13 15:57:46 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.135 2006/06/13 13:12:18 dmitry Exp $ */ +/* $Id: iconv.c,v 1.136 2006/06/13 15:57:46 andrei Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -107,6 +107,15 @@ ZEND_GET_MODULE(iconv) #endif +/* {{{ PHP_GINIT_FUNCTION */ +static PHP_GINIT_FUNCTION(iconv) +{ + iconv_globals-input_encoding = NULL; + iconv_globals-output_encoding = NULL; + iconv_globals-internal_encoding = NULL; +} +/* }}} */ + #ifdef HAVE_LIBICONV #define iconv libiconv #endif @@ -156,15 +165,6 @@ PHP_INI_END() /* }}} */ -/* {{{ PHP_GINIT_FUNCTION */ -static PHP_GINIT_FUNCTION(iconv) -{ - iconv_globals-input_encoding = NULL; - iconv_globals-output_encoding = NULL; - iconv_globals-internal_encoding = NULL; -} -/* }}} */ - /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(miconv) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c /ext/iconv/tests bug37176.phpt
moriyoshi Thu Apr 27 00:49:18 2006 UTC Added files: /php-src/ext/iconv/testsbug37176.phpt Modified files: /php-src/ext/iconv iconv.c Log: - Fix bug #37176 (iconv_strpos() fails to find a string) http://cvs.php.net/viewcvs.cgi/php-src/ext/iconv/iconv.c?r1=1.132r2=1.133diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.132 php-src/ext/iconv/iconv.c:1.133 --- php-src/ext/iconv/iconv.c:1.132 Fri Feb 24 16:04:55 2006 +++ php-src/ext/iconv/iconv.c Thu Apr 27 00:49:17 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.132 2006/02/24 16:04:55 derick Exp $ */ +/* $Id: iconv.c,v 1.133 2006/04/27 00:49:17 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -797,6 +797,7 @@ } if (offset = 0) { if (cnt = (unsigned int)offset) { + fprintf(stderr, %s %s\n, ndl_buf_p, buf); if (_php_iconv_memequal(buf, ndl_buf_p, sizeof(buf))) { if (match_ofs == (unsigned int)-1) { match_ofs = cnt; @@ -825,18 +826,16 @@ j += GENERIC_SUPERSET_NBYTES; } - if (!_php_iconv_memequal(buf, ndl_buf[i], sizeof(buf))) { - i = 0; - } - - if (i == 0) { - match_ofs = (unsigned int)-1; - } else { + if (_php_iconv_memequal(buf, ndl_buf[i], sizeof(buf))) { match_ofs += (lim - i) / GENERIC_SUPERSET_NBYTES; i += GENERIC_SUPERSET_NBYTES; + ndl_buf_p = ndl_buf[i]; + ndl_buf_left = ndl_buf_len - i; + } else { + match_ofs = (unsigned int)-1; + ndl_buf_p = ndl_buf; + ndl_buf_left = ndl_buf_len; } - ndl_buf_p = ndl_buf[i]; - ndl_buf_left = ndl_buf_len - i; } } } else { @@ -870,18 +869,16 @@ j += GENERIC_SUPERSET_NBYTES; } - if (!_php_iconv_memequal(buf, ndl_buf[i], sizeof(buf))) { - i = 0; - } - - if (i == 0) { - match_ofs = (unsigned int)-1; - } else { + if (_php_iconv_memequal(buf, ndl_buf[i], sizeof(buf))) { match_ofs += (lim - i) / GENERIC_SUPERSET_NBYTES; i += GENERIC_SUPERSET_NBYTES; + ndl_buf_p = ndl_buf[i]; + ndl_buf_left = ndl_buf_len - i; + } else { + match_ofs = (unsigned int)-1; + ndl_buf_p = ndl_buf; + ndl_buf_left = ndl_buf_len; } - ndl_buf_p = ndl_buf[i]; - ndl_buf_left = ndl_buf_len - i; } } } http://cvs.php.net/viewcvs.cgi/php-src/ext/iconv/tests/bug37176.phpt?view=markuprev=1.1 Index: php-src/ext/iconv/tests/bug37176.phpt +++ php-src/ext/iconv/tests/bug37176.phpt --TEST-- Bug #37176 (iconv_strpos() fails to find a string) --FILE-- ?php var_dump(iconv_strpos('11--','1-',0,'UTF-8')); var_dump(iconv_strpos('-11--','1-',0,'UTF-8')); ? --EXPECT-- int(1) int(2) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Thu Apr 27 03:53:01 2006 UTC Modified files: /php-src/ext/iconv iconv.c Log: - Remove fprintf() used for debugging http://cvs.php.net/viewcvs.cgi/php-src/ext/iconv/iconv.c?r1=1.133r2=1.134diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.133 php-src/ext/iconv/iconv.c:1.134 --- php-src/ext/iconv/iconv.c:1.133 Thu Apr 27 00:49:17 2006 +++ php-src/ext/iconv/iconv.c Thu Apr 27 03:53:01 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.133 2006/04/27 00:49:17 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.134 2006/04/27 03:53:01 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -797,7 +797,6 @@ } if (offset = 0) { if (cnt = (unsigned int)offset) { - fprintf(stderr, %s %s\n, ndl_buf_p, buf); if (_php_iconv_memequal(buf, ndl_buf_p, sizeof(buf))) { if (match_ofs == (unsigned int)-1) { match_ofs = cnt; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
derick Fri Feb 24 16:04:55 2006 UTC Modified files: /php-src/ext/iconv iconv.c Log: - Fixed issue with iconv_mime_decode where the encoding would only allow upper case specifiers. #- See RFC 2047, section 2. http://cvs.php.net/viewcvs.cgi/php-src/ext/iconv/iconv.c?r1=1.131r2=1.132diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.131 php-src/ext/iconv/iconv.c:1.132 --- php-src/ext/iconv/iconv.c:1.131 Sun Jan 1 13:09:50 2006 +++ php-src/ext/iconv/iconv.c Fri Feb 24 16:04:55 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.131 2006/01/01 13:09:50 sniper Exp $ */ +/* $Id: iconv.c,v 1.132 2006/02/24 16:04:55 derick Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1398,11 +1398,13 @@ case 3: /* expecting a encoding scheme specifier */ switch (*p1) { + case 'b': case 'B': enc_scheme = PHP_ICONV_ENC_SCHEME_BASE64; scan_stat = 4; break; + case 'q': case 'Q': enc_scheme = PHP_ICONV_ENC_SCHEME_QPRINT; scan_stat = 4; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Thu Dec 15 22:47:27 2005 EDT Modified files: /php-src/ext/iconv iconv.c Log: fix #35692(iconv_mime_decode() segfault, with libiconv only) http://cvs.php.net/viewcvs.cgi/php-src/ext/iconv/iconv.c?r1=1.129r2=1.130diff_format=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.129 php-src/ext/iconv/iconv.c:1.130 --- php-src/ext/iconv/iconv.c:1.129 Tue Dec 6 02:24:31 2005 +++ php-src/ext/iconv/iconv.c Thu Dec 15 22:47:27 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.129 2005/12/06 02:24:31 sniper Exp $ */ +/* $Id: iconv.c,v 1.130 2005/12/15 22:47:27 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1369,7 +1369,7 @@ if (cd == (iconv_t)(-1)) { if ((mode PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Thu Oct 20 12:50:45 2005 EDT Modified files: /php-src/ext/iconv iconv.c Log: use constants instead of their values http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.127r2=1.128ty=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.127 php-src/ext/iconv/iconv.c:1.128 --- php-src/ext/iconv/iconv.c:1.127 Tue Oct 11 09:59:18 2005 +++ php-src/ext/iconv/iconv.c Thu Oct 20 12:50:43 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.127 2005/10/11 13:59:18 tony2001 Exp $ */ +/* $Id: iconv.c,v 1.128 2005/10/20 16:50:43 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1245,7 +1245,7 @@ const char *encoded_word = NULL; const char *spaces = NULL; - php_iconv_enc_scheme_t enc_scheme = 0; + php_iconv_enc_scheme_t enc_scheme = PHP_ICONV_ENC_SCHEME_BASE64; if (next_pos != NULL) { *next_pos = NULL; @@ -1704,7 +1704,7 @@ if (scan_stat == 1) { _php_iconv_appendc(pretval, '=', cd_pl); } - err = 0; + err = PHP_ICONV_ERR_SUCCESS; } else { err = PHP_ICONV_ERR_MALFORMED; goto out; @@ -2079,7 +2079,7 @@ int charset_len; long mode = 0; - php_iconv_err_t err = 0; + php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS; charset = ICONVG(internal_encoding); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Tue Oct 11 09:59:19 2005 EDT Modified files: /php-src/ext/iconv iconv.c Log: MF51: fix #34757 (iconv_substr() gives Unknown error when offset string length) http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.126r2=1.127ty=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.126 php-src/ext/iconv/iconv.c:1.127 --- php-src/ext/iconv/iconv.c:1.126 Thu Sep 8 07:48:07 2005 +++ php-src/ext/iconv/iconv.c Tue Oct 11 09:59:18 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.126 2005/09/08 11:48:07 tony2001 Exp $ */ +/* $Id: iconv.c,v 1.127 2005/10/11 13:59:18 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -586,26 +586,38 @@ size_t out_left; unsigned int cnt; - + unsigned int total_len; + + err = _php_iconv_strlen(total_len, str, nbytes, enc); + if (err != PHP_ICONV_ERR_SUCCESS) { + return err; + } + /* normalize the offset and the length */ - if (offset 0 || len 0) { - unsigned int total_len; - err = _php_iconv_strlen(total_len, str, nbytes, enc); - if (err != PHP_ICONV_ERR_SUCCESS) { - return err; - } - if (offset 0) { - if ((offset += total_len) 0) { - offset = 0; - } + if (offset 0) { + if ((offset += total_len) 0) { + offset = 0; } - if (len 0) { - if ((len += (total_len - offset)) 0) { - len = 0; - } + } + if (len 0) { + if ((len += (total_len - offset)) 0) { + len = 0; } } + if (offset = total_len) { + return PHP_ICONV_ERR_SUCCESS; + } + + if ((offset + len) total_len) { + /* trying to compute the length */ + len = total_len - offset; + } + + if (len == 0) { + return PHP_ICONV_ERR_SUCCESS; + } + cd1 = iconv_open(GENERIC_SUPERSET_NAME, enc); if (cd1 == (iconv_t)(-1)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
tony2001Thu Sep 8 07:48:09 2005 EDT Modified files: /php-src/ext/iconv iconv.c Log: fix phpinfo() output for iconv extension (convert unicode values to string before outputting them) http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.125r2=1.126ty=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.125 php-src/ext/iconv/iconv.c:1.126 --- php-src/ext/iconv/iconv.c:1.125 Thu Aug 11 19:35:53 2005 +++ php-src/ext/iconv/iconv.c Thu Sep 8 07:48:07 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.125 2005/08/11 23:35:53 andrei Exp $ */ +/* $Id: iconv.c,v 1.126 2005/09/08 11:48:07 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -216,6 +216,9 @@ zend_get_constant(ICONV_IMPL, sizeof(ICONV_IMPL)-1, iconv_impl TSRMLS_CC); zend_get_constant(ICONV_VERSION, sizeof(ICONV_VERSION)-1, iconv_ver TSRMLS_CC); + convert_to_string(iconv_impl); + convert_to_string(iconv_ver); + php_info_print_table_start(); php_info_print_table_row(2, iconv support, enabled); php_info_print_table_row(2, iconv implementation, Z_STRVAL(iconv_impl)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/iconv iconv.c
On Thu, 9 Jun 2005, Derick Rethans wrote: On Wed, 8 Jun 2005, Ilia Alshanetsky wrote: iliaa Wed Jun 8 19:49:40 2005 EDT Modified files: /php-src/ext/iconv iconv.c Log: Fixed bug #33268 (iconv_strlen() works only with a parameter of 3 in length) No merge to 4.4? Ilia? Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/iconv iconv.c
On Wed, 8 Jun 2005, Ilia Alshanetsky wrote: iliaa Wed Jun 8 19:49:40 2005 EDT Modified files: /php-src/ext/iconviconv.c Log: Fixed bug #33268 (iconv_strlen() works only with a parameter of 3 in length) No merge to 4.4? Derick -- Derick Rethans http://derickrethans.nl | http://ez.no | http://xdebug.org -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/iconv iconv.c
On Wed, 8 Jun 2005, Ilia Alshanetsky wrote: iliaa Wed Jun 8 19:49:40 2005 EDT Modified files: /php-src/ext/iconv iconv.c Log: Fixed bug #33268 (iconv_strlen() works only with a parameter of 3 in length) http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.122r2=1.123ty=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.122 php-src/ext/iconv/iconv.c:1.123 --- php-src/ext/iconv/iconv.c:1.122 Wed Mar 23 18:06:38 2005 +++ php-src/ext/iconv/iconv.c Wed Jun 8 19:49:38 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.122 2005/03/23 23:06:38 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.123 2005/06/08 23:49:38 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -516,7 +516,7 @@ #endif } - out_left = 0; + errno = out_left = 0; for (in_p = str, in_left = nbytes, cnt = 0; in_left 0; cnt+=2) { size_t prev_in_left; @@ -547,6 +547,7 @@ break; case E2BIG: + case 0: *pretval = cnt; break; -- Donate @ http://pecl.php.net/wishlist.php/sniper -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
iliaa Wed Jun 8 19:49:40 2005 EDT Modified files: /php-src/ext/iconv iconv.c Log: Fixed bug #33268 (iconv_strlen() works only with a parameter of 3 in length) http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.122r2=1.123ty=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.122 php-src/ext/iconv/iconv.c:1.123 --- php-src/ext/iconv/iconv.c:1.122 Wed Mar 23 18:06:38 2005 +++ php-src/ext/iconv/iconv.c Wed Jun 8 19:49:38 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.122 2005/03/23 23:06:38 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.123 2005/06/08 23:49:38 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -516,7 +516,7 @@ #endif } - out_left = 0; + errno = out_left = 0; for (in_p = str, in_left = nbytes, cnt = 0; in_left 0; cnt+=2) { size_t prev_in_left; @@ -547,6 +547,7 @@ break; case E2BIG: + case 0: *pretval = cnt; break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Wed Mar 23 18:06:38 2005 EDT Modified files: /php-src/ext/iconv iconv.c Log: - Add sanity check in iconv_mime_encode(). Leaving the third parameter unspecified would yield bus error. http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.121r2=1.122ty=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.121 php-src/ext/iconv/iconv.c:1.122 --- php-src/ext/iconv/iconv.c:1.121 Tue Nov 23 04:44:54 2004 +++ php-src/ext/iconv/iconv.c Wed Mar 23 18:06:38 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.121 2004/11/23 09:44:54 derick Exp $ */ +/* $Id: iconv.c,v 1.122 2005/03/23 23:06:38 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1909,24 +1909,20 @@ Composes a mime header field with field_name and field_value in a specified scheme */ PHP_FUNCTION(iconv_mime_encode) { - char *field_name; + const char *field_name = NULL; int field_name_len; - char *field_value; + const char *field_value = NULL; int field_value_len; - zval *pref; - zval val, *pval, **ppval; - char *in_charset; - char *out_charset; - long line_len = 76; - zval lfchars; - - php_iconv_enc_scheme_t scheme_id = PHP_ICONV_ENC_SCHEME_BASE64; - + zval *pref = NULL; + zval tmp_zv, *tmp_zv_p = NULL; smart_str retval = {0}; - php_iconv_err_t err; - in_charset = ICONVG(internal_encoding); + const char *in_charset = ICONVG(internal_encoding); + const char *out_charset = in_charset; + long line_len = 76; + const char *lfchars = \r\n; + php_iconv_enc_scheme_t scheme_id = PHP_ICONV_ENC_SCHEME_BASE64; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|a, field_name, field_name_len, field_value, field_value_len, @@ -1935,65 +1931,70 @@ RETURN_FALSE; } - if (zend_hash_find(Z_ARRVAL_P(pref), scheme, sizeof(scheme), (void **)ppval) == SUCCESS) { - if (Z_TYPE_PP(ppval) == IS_STRING Z_STRLEN_PP(ppval) 0) { - switch (Z_STRVAL_PP(ppval)[0]) { - case 'B': case 'b': - scheme_id = PHP_ICONV_ENC_SCHEME_BASE64; - break; + if (pref != NULL) { + zval **ppval; - case 'Q': case 'q': - scheme_id = PHP_ICONV_ENC_SCHEME_QPRINT; - break; + if (zend_hash_find(Z_ARRVAL_P(pref), scheme, sizeof(scheme), (void **)ppval) == SUCCESS) { + if (Z_TYPE_PP(ppval) == IS_STRING Z_STRLEN_PP(ppval) 0) { + switch (Z_STRVAL_PP(ppval)[0]) { + case 'B': case 'b': + scheme_id = PHP_ICONV_ENC_SCHEME_BASE64; + break; + + case 'Q': case 'q': + scheme_id = PHP_ICONV_ENC_SCHEME_QPRINT; + break; + } } } - } - - in_charset = ICONVG(internal_encoding); - if (zend_hash_find(Z_ARRVAL_P(pref), input-charset, sizeof(input-charset), (void **)ppval) == SUCCESS) { - if (Z_TYPE_PP(ppval) == IS_STRING Z_STRLEN_PP(ppval) 0) { - in_charset = Z_STRVAL_PP(ppval); + if (zend_hash_find(Z_ARRVAL_P(pref), input-charset, sizeof(input-charset), (void **)ppval) == SUCCESS) { + if (Z_TYPE_PP(ppval) == IS_STRING Z_STRLEN_PP(ppval) 0) { + in_charset = Z_STRVAL_PP(ppval); + } } - } - out_charset = in_charset; - if (zend_hash_find(Z_ARRVAL_P(pref), output-charset, sizeof(output-charset), (void **)ppval) == SUCCESS) { - if (Z_TYPE_PP(ppval) == IS_STRING Z_STRLEN_PP(ppval) 0) { - out_charset = Z_STRVAL_PP(ppval); + if (zend_hash_find(Z_ARRVAL_P(pref), output-charset, sizeof(output-charset), (void **)ppval) == SUCCESS) { + if (Z_TYPE_PP(ppval) == IS_STRING Z_STRLEN_PP(ppval) 0) { + out_charset = Z_STRVAL_PP(ppval); + } } - } - if (zend_hash_find(Z_ARRVAL_P(pref), line-length, sizeof(line-length), (void **)ppval) == SUCCESS) { - pval = *ppval; - if (Z_TYPE_P(pval) != IS_LONG) { - val = *pval; - zval_copy_ctor(val); - convert_to_long(val); -
[PHP-CVS] cvs: php-src /ext/iconv iconv.c php_iconv.h
derick Tue Nov 23 04:44:54 2004 EDT Modified files: /php-src/ext/iconv iconv.c php_iconv.h Log: - Export php_iconv_string(). http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.120r2=1.121ty=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.120 php-src/ext/iconv/iconv.c:1.121 --- php-src/ext/iconv/iconv.c:1.120 Fri Aug 13 10:52:27 2004 +++ php-src/ext/iconv/iconv.c Tue Nov 23 04:44:54 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.120 2004/08/13 14:52:27 tony2001 Exp $ */ +/* $Id: iconv.c,v 1.121 2004/11/23 09:44:54 derick Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -106,20 +106,6 @@ #define iconv libiconv #endif -/* {{{ typedef enum php_iconv_err_t */ -typedef enum _php_iconv_err_t { - PHP_ICONV_ERR_SUCCESS = SUCCESS, - PHP_ICONV_ERR_CONVERTER = 1, - PHP_ICONV_ERR_WRONG_CHARSET = 2, - PHP_ICONV_ERR_TOO_BIG = 3, - PHP_ICONV_ERR_ILLEGAL_SEQ = 4, - PHP_ICONV_ERR_ILLEGAL_CHAR = 5, - PHP_ICONV_ERR_UNKNOWN = 6, - PHP_ICONV_ERR_MALFORMED = 7, - PHP_ICONV_ERR_ALLOC = 8 -} php_iconv_err_t; -/* }}} */ - /* {{{ typedef enum php_iconv_enc_scheme_t */ typedef enum _php_iconv_enc_scheme_t { PHP_ICONV_ENC_SCHEME_BASE64, @@ -134,8 +120,6 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, iconv_t cd); static php_iconv_err_t _php_iconv_appendc(smart_str *d, const char c, iconv_t cd); -static php_iconv_err_t php_iconv_string(const char * in_p, size_t in_len, char **out, size_t *out_len, const char *out_charset, const char *in_charset); - static void _php_iconv_show_error(php_iconv_err_t err, const char *out_charset, const char *in_charset TSRMLS_DC); static php_iconv_err_t _php_iconv_strlen(unsigned int *pretval, const char *str, size_t nbytes, const char *enc); @@ -335,7 +319,7 @@ /* {{{ php_iconv_string() */ -php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, +PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, char **out, size_t *out_len, const char *out_charset, const char *in_charset) { http://cvs.php.net/diff.php/php-src/ext/iconv/php_iconv.h?r1=1.22r2=1.23ty=u Index: php-src/ext/iconv/php_iconv.h diff -u php-src/ext/iconv/php_iconv.h:1.22 php-src/ext/iconv/php_iconv.h:1.23 --- php-src/ext/iconv/php_iconv.h:1.22 Thu Jan 8 12:32:11 2004 +++ php-src/ext/iconv/php_iconv.h Tue Nov 23 04:44:54 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Revision: 1.22 $ */ +/* $Revision: 1.23 $ */ #ifndef PHP_ICONV_H #define PHP_ICONV_H @@ -75,6 +75,22 @@ #define ICONV_OUTPUT_ENCODING ISO-8859-1 #define ICONV_INTERNAL_ENCODING ISO-8859-1 +/* {{{ typedef enum php_iconv_err_t */ +typedef enum _php_iconv_err_t { + PHP_ICONV_ERR_SUCCESS = SUCCESS, + PHP_ICONV_ERR_CONVERTER = 1, + PHP_ICONV_ERR_WRONG_CHARSET = 2, + PHP_ICONV_ERR_TOO_BIG = 3, + PHP_ICONV_ERR_ILLEGAL_SEQ = 4, + PHP_ICONV_ERR_ILLEGAL_CHAR = 5, + PHP_ICONV_ERR_UNKNOWN = 6, + PHP_ICONV_ERR_MALFORMED = 7, + PHP_ICONV_ERR_ALLOC = 8 +} php_iconv_err_t; +/* }}} */ + +PHP_ICONV_API php_iconv_err_t php_iconv_string(const char * in_p, size_t in_len, char **out, size_t *out_len, const char *in_charset, const char *out_charset); + #else #define iconv_module_ptr NULL -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/iconv iconv.c
Hi, On 2004/08/16, at 16:22, Antony Dovgal wrote: If you think it's wrong, I'll revert it, of course. But I saw some similar casts in the same file and thought that it's logically right to add one here too. Nevermind. Perhaps I was thinking of something opposite. You are perfectly logical on this :-) 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/iconv iconv.c
On Sat, 14 Aug 2004 12:40:33 +0900 Moriyoshi Koizumi [EMAIL PROTECTED] wrote: Antony Dovgal wrote: #include config.h @@ -2457,7 +2457,7 @@ while (icnt 0) { if ((ps == NULL ? iconv(self-cd, NULL, NULL, pd, ocnt): -iconv(self-cd, ps, icnt, pd, ocnt)) == (size_t)-1) {+ iconv(self-cd, (char **)ps, icnt, pd, ocnt)) == (size_t)-1) { #if ICONV_SUPPORTS_ERRNO switch (errno) { case EILSEQ: I'm afraid it doesn't make much sense. Please have a look at http://marc.theaimsgroup.com/?l=php-devm=10627977767w=2 and consider reverting. If you think it's wrong, I'll revert it, of course. But I saw some similar casts in the same file and thought that it's logically right to add one here too. -- Wbr, Antony Dovgal aka tony2001 [EMAIL PROTECTED] || [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/iconv iconv.c
Antony Dovgal wrote: #include config.h @@ -2457,7 +2457,7 @@ while (icnt 0) { if ((ps == NULL ? iconv(self-cd, NULL, NULL, pd, ocnt): - iconv(self-cd, ps, icnt, pd, ocnt)) == (size_t)-1) { + iconv(self-cd, (char **)ps, icnt, pd, ocnt)) == (size_t)-1) { #if ICONV_SUPPORTS_ERRNO switch (errno) { case EILSEQ: I'm afraid it doesn't make much sense. Please have a look at http://marc.theaimsgroup.com/?l=php-devm=10627977767w=2 and consider reverting. Moriyoshi -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Tue Jul 20 14:46:39 2004 EDT Modified files: /php-src/ext/iconv iconv.c Log: - Fix possible leaks / segfaults in persistent filter http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.118r2=1.119ty=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.118 php-src/ext/iconv/iconv.c:1.119 --- php-src/ext/iconv/iconv.c:1.118 Mon Jul 19 04:34:18 2004 +++ php-src/ext/iconv/iconv.c Tue Jul 20 14:46:39 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.118 2004/07/19 08:34:18 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.119 2004/07/20 18:46:39 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2344,7 +2344,7 @@ /* }}} */ /* {{{ php_iconv_stream_filter_append_bucket */ -static size_t php_iconv_stream_filter_append_bucket( +static int php_iconv_stream_filter_append_bucket( php_iconv_stream_filter *self, php_stream *stream, php_stream_filter *filter, php_stream_bucket_brigade *buckets_out, @@ -2367,7 +2367,11 @@ } out_buf_size = ocnt = prev_ocnt = initial_out_buf_size; - out_buf = pd = pemalloc(out_buf_size, self-persistent); + if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) { + return FAILURE; + } + + pd = out_buf; if (self-stub_len 0) { pt = self-stub; @@ -2407,14 +2411,26 @@ if (new_out_buf_size out_buf_size) { /* whoa! no bigger buckets are sold anywhere... */ - new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, self-persistent TSRMLS_CC); + if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) { + goto out_failure; + } php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC); out_buf_size = ocnt = initial_out_buf_size; - out_buf = pd = pemalloc(out_buf_size, self-persistent); + if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) { + return FAILURE; + } + pd = out_buf; } else { - new_out_buf = perealloc(out_buf, new_out_buf_size, self-persistent); + if (NULL == (new_out_buf = perealloc(out_buf, new_out_buf_size, persistent))) { + if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) { + goto out_failure; + } + + php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC); + return FAILURE; + } pd = new_out_buf + (pd - out_buf); ocnt += (new_out_buf_size - out_buf_size); out_buf = new_out_buf; @@ -2472,14 +2488,26 @@ if (new_out_buf_size out_buf_size) { /* whoa! no bigger buckets are sold anywhere... */ - new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, self-persistent TSRMLS_CC); + if (NULL == (new_bucket = php_stream_bucket_new(stream, out_buf, (out_buf_size - ocnt), 1, persistent TSRMLS_CC))) { + goto out_failure; + } php_stream_bucket_append(buckets_out, new_bucket TSRMLS_CC); out_buf_size = ocnt = initial_out_buf_size; - out_buf = pd = pemalloc(out_buf_size,
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Mon Jul 19 04:34:18 2004 EDT Modified files: /php-src/ext/iconv iconv.c Log: - Fix a bug in iconv stream filter that prevents pending buckets from being processed on flush operation (same issue pollita fixed several days ago). http://cvs.php.net/diff.php/php-src/ext/iconv/iconv.c?r1=1.117r2=1.118ty=u Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.117 php-src/ext/iconv/iconv.c:1.118 --- php-src/ext/iconv/iconv.c:1.117 Thu Jan 8 03:15:47 2004 +++ php-src/ext/iconv/iconv.c Mon Jul 19 04:34:18 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.117 2004/01/08 08:15:47 andi Exp $ */ +/* $Id: iconv.c,v 1.118 2004/07/19 08:34:18 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2531,27 +2531,27 @@ size_t consumed = 0; php_iconv_stream_filter *self = (php_iconv_stream_filter *)filter-abstract; - if (flags != PSFS_FLAG_NORMAL) { - if (php_iconv_stream_filter_append_bucket(self, stream, filter, buckets_out, NULL, 0, consumed, self-persistent TSRMLS_CC) != SUCCESS) { - goto out_failure; - } - } else { - while (buckets_in-head != NULL) { - bucket = buckets_in-head; + while (buckets_in-head != NULL) { + bucket = buckets_in-head; - php_stream_bucket_unlink(bucket TSRMLS_CC); + php_stream_bucket_unlink(bucket TSRMLS_CC); - if (php_iconv_stream_filter_append_bucket(self, stream, filter, buckets_out, bucket-buf, bucket-buflen, consumed, self-persistent TSRMLS_CC) != SUCCESS) { goto out_failure; - } + if (php_iconv_stream_filter_append_bucket(self, stream, filter, buckets_out, bucket-buf, bucket-buflen, consumed, self-persistent TSRMLS_CC) != SUCCESS) { goto out_failure; + } - php_stream_bucket_delref(bucket TSRMLS_CC); + php_stream_bucket_delref(bucket TSRMLS_CC); + } + + if (flags != PSFS_FLAG_NORMAL) { + if (php_iconv_stream_filter_append_bucket(self, stream, filter, buckets_out, NULL, 0, consumed, self-persistent TSRMLS_CC) != SUCCESS) { + goto out_failure; } } - if (bytes_consumed) { + if (bytes_consumed != NULL) { *bytes_consumed = consumed; } - + return PSFS_PASS_ON; out_failure: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Tue Jan 6 09:22:54 2004 EDT Modified files: /php-src/ext/iconv iconv.c Log: Prevent a character from being wrongly doubled in the buffer. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.115 php-src/ext/iconv/iconv.c:1.116 --- php-src/ext/iconv/iconv.c:1.115 Sat Dec 27 18:07:47 2003 +++ php-src/ext/iconv/iconv.c Tue Jan 6 09:22:54 2004 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.115 2003/12/27 23:07:47 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.116 2004/01/06 14:22:54 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1580,7 +1580,7 @@ if (err != PHP_ICONV_ERR_SUCCESS) { if ((mode PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { /* pass the entire chunk through the converter */ - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + err = _php_iconv_appendl(pretval, encoded_word, (size_t)(p1 - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Sat Dec 27 18:05:24 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: - Add missing sanity check. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.113 php-src/ext/iconv/iconv.c:1.114 --- php-src/ext/iconv/iconv.c:1.113 Tue Dec 23 21:36:21 2003 +++ php-src/ext/iconv/iconv.c Sat Dec 27 18:05:23 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.113 2003/12/24 02:36:21 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.114 2003/12/27 23:05:23 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2102,6 +2102,10 @@ break; } + if (decoded_header.c != NULL) { + break; + } + limit = decoded_header.c + decoded_header.len; for (p = decoded_header.c; p limit; p++) { if (*p == ':') { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Sat Dec 27 18:07:48 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Just laugh at me :) Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.114 php-src/ext/iconv/iconv.c:1.115 --- php-src/ext/iconv/iconv.c:1.114 Sat Dec 27 18:05:23 2003 +++ php-src/ext/iconv/iconv.c Sat Dec 27 18:07:47 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.114 2003/12/27 23:05:23 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.115 2003/12/27 23:07:47 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2102,7 +2102,7 @@ break; } - if (decoded_header.c != NULL) { + if (decoded_header.c == NULL) { break; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
iliaa Tue Dec 23 12:05:44 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Fixed compiler warnings. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.110 php-src/ext/iconv/iconv.c:1.111 --- php-src/ext/iconv/iconv.c:1.110 Sun Dec 21 20:30:00 2003 +++ php-src/ext/iconv/iconv.c Tue Dec 23 12:05:43 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.110 2003/12/22 01:30:00 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.111 2003/12/23 17:05:43 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1241,11 +1241,11 @@ const char *csname = NULL; size_t csname_len; const char *encoded_text = NULL; - size_t encoded_text_len; + size_t encoded_text_len = 0; const char *encoded_word = NULL; const char *spaces = NULL; - php_iconv_enc_scheme_t enc_scheme; + php_iconv_enc_scheme_t enc_scheme = {0}; if (next_pos != NULL) { *next_pos = NULL; @@ -1537,6 +1537,9 @@ case PHP_ICONV_ENC_SCHEME_QPRINT: decoded_text = (char *)php_quot_print_decode((unsigned char*)encoded_text, (int)encoded_text_len, decoded_text_len, 1); break; + default: + decoded_text = NULL; + break; } if (decoded_text == NULL) { @@ -2058,7 +2061,7 @@ int charset_len; long mode = 0; - php_iconv_err_t err; + php_iconv_err_t err = {0}; charset = ICONVG(internal_encoding); @@ -2072,10 +2075,10 @@ while (encoded_str_len 0) { smart_str decoded_header = {0}; - char *header_name; - size_t header_name_len; + char *header_name = NULL; + size_t header_name_len = 0; char *header_value = NULL; - size_t header_value_len; + size_t header_value_len = 0; char *p, *limit; const char *next_pos; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Tue Dec 23 12:11:02 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Those are not structures :-) Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.111 php-src/ext/iconv/iconv.c:1.112 --- php-src/ext/iconv/iconv.c:1.111 Tue Dec 23 12:05:43 2003 +++ php-src/ext/iconv/iconv.c Tue Dec 23 12:10:54 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.111 2003/12/23 17:05:43 iliaa Exp $ */ +/* $Id: iconv.c,v 1.112 2003/12/23 17:10:54 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1245,7 +1245,7 @@ const char *encoded_word = NULL; const char *spaces = NULL; - php_iconv_enc_scheme_t enc_scheme = {0}; + php_iconv_enc_scheme_t enc_scheme = 0; if (next_pos != NULL) { *next_pos = NULL; @@ -2061,7 +2061,7 @@ int charset_len; long mode = 0; - php_iconv_err_t err = {0}; + php_iconv_err_t err = 0; charset = ICONVG(internal_encoding); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Tue Dec 23 21:36:22 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: - Supply some comments. Hope those help when you have to debug this dead beef. - Fix iconv_mime_decode() to correctly handle malformed headers :) - Fix iconv_mime_decode() bug, that the result is mangled when ICONV_MIME_CONTINUE_ON_ERROR is enabled and the function encounters an unconvertable encoded chunk. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.112 php-src/ext/iconv/iconv.c:1.113 --- php-src/ext/iconv/iconv.c:1.112 Tue Dec 23 12:10:54 2003 +++ php-src/ext/iconv/iconv.c Tue Dec 23 21:36:21 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.112 2003/12/23 17:10:54 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.113 2003/12/24 02:36:21 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1271,9 +1271,9 @@ int eos = 0; switch (scan_stat) { - case 0: + case 0: /* expecting any character */ switch (*p1) { - case '\r': + case '\r': /* part of an EOL sequence? */ scan_stat = 7; break; @@ -1281,17 +1281,17 @@ scan_stat = 8; break; - case '=': + case '=': /* first letter of an encoded chunk */ encoded_word = p1; scan_stat = 1; break; - case ' ': case '\t': + case ' ': case '\t': /* a chunk of whitespaces */ spaces = p1; scan_stat = 11; break; - default: + default: /* first letter of a non-encoded word */ _php_iconv_appendc(pretval, *p1, cd_pl); encoded_word = NULL; if ((mode PHP_ICONV_MIME_DECODE_STRICT)) { @@ -1301,7 +1301,7 @@ } break; - case 1: + case 1: /* expecting a delimiter */ if (*p1 != '?') { err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err != PHP_ICONV_ERR_SUCCESS) { @@ -1319,13 +1319,13 @@ scan_stat = 2; break; - case 2: /* charset name */ + case 2: /* expecting a charset name */ switch (*p1) { - case '?': + case '?': /* normal delimiter: encoding scheme follows */ scan_stat = 3; break; - case '*': + case '*': /* new style delimiter: locale id follows */ scan_stat = 10; break; } @@ -1396,7 +1396,7 @@ } break; - case 3: + case 3: /* expecting a encoding scheme specifier */ switch (*p1) { case 'B': enc_scheme = PHP_ICONV_ENC_SCHEME_BASE64; @@ -1428,9 +1428,10 @@ } break; - case 4: + case 4: /* expecting a delimiter */ if (*p1 != '?') { if ((mode PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { + /* pass the entire chunk through the converter */ err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); if (err !=
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Sun Dec 21 20:30:02 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: - Fix multibyte handling errors in iconv_mime_encode() when quoted-printable encoding scheme is used. - Fix segfault that occurs in iconv_mime_encode() when input_charset or output_charset parameter is not specified in the associative array. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.109 php-src/ext/iconv/iconv.c:1.110 --- php-src/ext/iconv/iconv.c:1.109 Sun Dec 7 19:38:00 2003 +++ php-src/ext/iconv/iconv.c Sun Dec 21 20:30:00 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.109 2003/12/08 00:38:00 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.110 2003/12/22 01:30:00 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -911,6 +911,24 @@ size_t in_left; char *out_p; size_t out_left; + static int qp_table[256] = { + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x00 */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 */ + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x20 */ + 1, 1, 1, 1, 1, 1, 1 ,1, 1, 1, 1, 1, 1, 3, 1, 3, /* 0x30 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, /* 0x50 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, /* 0x70 */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x80 */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x90 */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xA0 */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xB0 */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xC0 */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xD0 */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xE0 */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 /* 0xF0 */ + }; out_charset_len = strlen(out_charset); lfchars_len = strlen(lfchars); @@ -1086,16 +1104,26 @@ } break; /* case PHP_ICONV_ENC_SCHEME_BASE64: */ case PHP_ICONV_ENC_SCHEME_QPRINT: { + size_t ini_in_left; + const char *ini_in_p; + const unsigned char *p; + size_t nbytes_required; + smart_str_appendc(pretval, 'Q'); char_cnt--; smart_str_appendc(pretval, '?'); char_cnt--; - prev_in_left = in_left; + prev_in_left = ini_in_left = in_left; + ini_in_p = in_p; + + for (out_size = char_cnt; out_size 0;) { + size_t prev_out_left; + + nbytes_required = 0; - while (in_left 0) { out_p = buf; - out_left = out_size = 1; + out_left = out_size; if (iconv(cd, (char **)in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { #if ICONV_SUPPORTS_ERRNO @@ -1109,6 +1137,10 @@ goto out; case E2BIG: + if (prev_in_left == in_left) { + err = PHP_ICONV_ERR_UNKNOWN; + goto out; + } break; default: @@ -1123,36 +1155,47 @@ #endif } - if (out_size out_left) { - if ((buf[0] = 33 buf[0] = 60) || - (buf[0] = 62 buf[0] = 126)) { - - if (char_cnt = 1 + 2) { - smart_str_appendc(pretval, buf[0]); - char_cnt--; - } else { -
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Sun Dec 7 19:38:01 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Fix iconv stream filter to properly handle multibyte characters that span at the alignment of a hunk. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.108 php-src/ext/iconv/iconv.c:1.109 --- php-src/ext/iconv/iconv.c:1.108 Sat Dec 6 06:10:13 2003 +++ php-src/ext/iconv/iconv.c Sun Dec 7 19:38:00 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.108 2003/12/06 11:10:13 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.109 2003/12/08 00:38:00 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2234,6 +2234,8 @@ size_t to_charset_len; char *from_charset; size_t from_charset_len; + char stub[128]; + size_t stub_len; } php_iconv_stream_filter; /* {{{ php_iconv_stream_filter_dtor */ @@ -2271,39 +2273,43 @@ return PHP_ICONV_ERR_UNKNOWN; } self-persistent = persistent; - + self-stub_len = 0; return PHP_ICONV_ERR_SUCCESS; } /* }}} */ -/* {{{ php_iconv_stream_filter_do_filter */ -static php_stream_filter_status_t php_iconv_stream_filter_do_filter( +/* {{{ php_iconv_stream_filter_append_bucket */ +static size_t php_iconv_stream_filter_append_bucket( + php_iconv_stream_filter *self, php_stream *stream, php_stream_filter *filter, - php_stream_bucket_brigade *buckets_in, php_stream_bucket_brigade *buckets_out, - size_t *bytes_consumed, int flags TSRMLS_DC) + const char *ps, size_t buf_len, size_t *consumed, + int persistent TSRMLS_DC) { - php_stream_bucket *bucket = NULL, *new_bucket; - size_t consumed = 0; - php_iconv_stream_filter *self = (php_iconv_stream_filter *)filter-abstract; + php_stream_bucket *new_bucket; char *out_buf = NULL; size_t out_buf_size; - char *pd; - size_t ocnt, prev_ocnt; - - if (flags != PSFS_FLAG_NORMAL) { - /* flush operation */ + char *pd, *pt; + size_t ocnt, prev_ocnt, icnt, tcnt; + size_t initial_out_buf_size; + + if (ps == NULL) { + initial_out_buf_size = 64; + icnt = 1; + } else { + initial_out_buf_size = buf_len; + icnt = buf_len; + } - out_buf_size = 64; - out_buf = pemalloc(out_buf_size, self-persistent); - ocnt = prev_ocnt = out_buf_size; - pd = out_buf; + out_buf_size = ocnt = prev_ocnt = initial_out_buf_size; + out_buf = pd = pemalloc(out_buf_size, self-persistent); - /* trying hard to reduce the number of buckets to hand to the -* next filter */ + if (self-stub_len 0) { + pt = self-stub; + tcnt = self-stub_len; - for (;;) { - if (iconv(self-cd, NULL, NULL, pd, ocnt) == (size_t)-1) { + while (tcnt 0) { + if (iconv(self-cd, pt, tcnt, pd, ocnt) == (size_t)-1) { #if ICONV_SUPPORTS_ERRNO switch (errno) { case EILSEQ: @@ -2311,12 +2317,46 @@ goto out_failure; case EINVAL: - php_error_docref(NULL TSRMLS_CC, E_WARNING, iconv stream filter (\%s\=\%s\): unexpected octet values, self-from_charset, self-to_charset); - goto out_failure; - - case E2BIG: + if (ps != NULL) { + if (icnt 0) { + if (self-stub_len = sizeof(self-stub)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, iconv stream filter (\%s\=\%s\): insufficient buffer, self-from_charset, self-to_charset); + goto out_failure; + } + self-stub[self-stub_len++] = *(ps++); + icnt--; + pt = self-stub; + tcnt = self-stub_len; + } else { + tcnt = 0; + break; +
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Sat Dec 6 06:10:14 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Add missing iconv_close() call Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.107 php-src/ext/iconv/iconv.c:1.108 --- php-src/ext/iconv/iconv.c:1.107 Fri Dec 5 04:35:21 2003 +++ php-src/ext/iconv/iconv.c Sat Dec 6 06:10:13 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.107 2003/12/05 09:35:21 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.108 2003/12/06 11:10:13 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2239,6 +2239,7 @@ /* {{{ php_iconv_stream_filter_dtor */ static void php_iconv_stream_filter_dtor(php_iconv_stream_filter *self) { + iconv_close(self-cd); pefree(self-to_charset, self-persistent); pefree(self-from_charset, self-persistent); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Fri Dec 5 04:35:22 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Add a missing marker Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.106 php-src/ext/iconv/iconv.c:1.107 --- php-src/ext/iconv/iconv.c:1.106 Thu Dec 4 22:14:54 2003 +++ php-src/ext/iconv/iconv.c Fri Dec 5 04:35:21 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.106 2003/12/05 03:14:54 wez Exp $ */ +/* $Id: iconv.c,v 1.107 2003/12/05 09:35:21 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2548,6 +2548,7 @@ return PHP_ICONV_ERR_SUCCESS; } /* }}} */ +/* }}} */ #endif /* -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Thu Dec 4 18:31:32 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Add iconv stream filter. # a quick synopsis: # # ?php # stream_filter_append(STDIN, 'convert.iconv.UTF-8/ISO-8859-15'); # # fpassthru(STDIN); # ? # Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.103 php-src/ext/iconv/iconv.c:1.104 --- php-src/ext/iconv/iconv.c:1.103 Tue Dec 2 02:36:42 2003 +++ php-src/ext/iconv/iconv.c Thu Dec 4 18:31:31 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.103 2003/12/02 07:36:42 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.104 2003/12/04 23:31:31 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -115,7 +115,8 @@ PHP_ICONV_ERR_ILLEGAL_SEQ = 4, PHP_ICONV_ERR_ILLEGAL_CHAR = 5, PHP_ICONV_ERR_UNKNOWN = 6, - PHP_ICONV_ERR_MALFORMED = 7 + PHP_ICONV_ERR_MALFORMED = 7, + PHP_ICONV_ERR_ALLOC = 8 } php_iconv_err_t; /* }}} */ @@ -146,6 +147,9 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fname, size_t fname_nbytes, const char *fval, size_t fval_nbytes, unsigned int max_line_len, const char *lfchars, php_iconv_enc_scheme_t enc_scheme, const char *out_charset, const char *enc); static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *str, size_t str_nbytes, const char *enc, const char **next_pos, int mode); + +static php_iconv_err_t php_iconv_stream_filter_register_factory(); +static php_iconv_err_t php_iconv_stream_filter_unregister_factory(); /* }}} */ /* {{{ static globals */ @@ -203,6 +207,10 @@ REGISTER_LONG_CONSTANT(ICONV_MIME_DECODE_STRICT, PHP_ICONV_MIME_DECODE_STRICT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(ICONV_MIME_DECODE_CONTINUE_ON_ERROR, PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR, CONST_CS | CONST_PERSISTENT); + if (php_iconv_stream_filter_register_factory() != PHP_ICONV_ERR_SUCCESS) { + return FAILURE; + } + return SUCCESS; } /* }}} */ @@ -210,6 +218,7 @@ /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(miconv) { + php_iconv_stream_filter_unregister_factory(); UNREGISTER_INI_ENTRIES(); return SUCCESS; } @@ -2212,6 +2221,328 @@ } /* }}} */ +/* {{{ iconv stream filter */ +typedef struct _php_iconv_stream_filter { + iconv_t cd; + int persistent; + char *to_charset; + size_t to_charset_len; + char *from_charset; + size_t from_charset_len; +} php_iconv_stream_filter; + +/* {{{ php_iconv_stream_filter_dtor */ +static void php_iconv_stream_filter_dtor(php_iconv_stream_filter *self) +{ + pefree(self-to_charset, self-persistent); + pefree(self-from_charset, self-persistent); +} +/* }}} */ + +/* {{{ php_iconv_stream_filter_ctor() */ +static php_iconv_err_t php_iconv_stream_filter_ctor(php_iconv_stream_filter *self, + const char *to_charset, size_t to_charset_len, + const char *from_charset, size_t from_charset_len, int persistent) +{ + if (NULL == (self-to_charset = pemalloc(to_charset_len + 1, persistent))) { + return PHP_ICONV_ERR_ALLOC; + } + self-to_charset_len = to_charset_len; + if (NULL == (self-from_charset = pemalloc(from_charset_len + 1, persistent))) { + pefree(self-to_charset, persistent); + return PHP_ICONV_ERR_ALLOC; + } + self-from_charset_len = from_charset_len; + + memcpy(self-to_charset, to_charset, to_charset_len); + self-to_charset[to_charset_len] = '\0'; + memcpy(self-from_charset, from_charset, from_charset_len); + self-from_charset[from_charset_len] = '\0'; + + if ((iconv_t)-1 == (self-cd = iconv_open(self-to_charset, self-from_charset))) { + pefree(self-from_charset, persistent); + pefree(self-to_charset, persistent); + return PHP_ICONV_ERR_UNKNOWN; + } + self-persistent = persistent; + + return PHP_ICONV_ERR_SUCCESS; +} +/* }}} */ + +/* {{{ php_iconv_stream_filter_do_filter */ +static php_stream_filter_status_t php_iconv_stream_filter_do_filter( + php_stream *stream, php_stream_filter *filter, + php_stream_bucket_brigade *buckets_in, + php_stream_bucket_brigade *buckets_out, + size_t *bytes_consumed, int flags TSRMLS_DC) +{ + php_stream_bucket *bucket = NULL, *new_bucket; + size_t consumed = 0; + php_iconv_stream_filter *self = (php_iconv_stream_filter *)filter-abstract; + char *out_buf = NULL; + size_t out_buf_size; + char *pd; + size_t ocnt, prev_ocnt; + + if (flags != PSFS_FLAG_NORMAL) { + /* flush operation */ + + out_buf_size = 64; +
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Thu Dec 4 18:46:54 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Type-punning is evil. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.104 php-src/ext/iconv/iconv.c:1.105 --- php-src/ext/iconv/iconv.c:1.104 Thu Dec 4 18:31:31 2003 +++ php-src/ext/iconv/iconv.c Thu Dec 4 18:46:53 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.104 2003/12/04 23:31:31 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.105 2003/12/04 23:46:53 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -985,6 +985,7 @@ size_t ini_in_left; const char *ini_in_p; size_t out_reserved = 4; + int dummy; smart_str_appendc(pretval, 'B'); char_cnt--; @@ -1066,7 +1067,9 @@ prev_in_left = in_left; - encoded = php_base64_encode(buf, (int)(out_size - out_left), encoded_len); + encoded = php_base64_encode(buf, (int)(out_size - out_left), dummy); + encoded_len = (size_t)dummy; + if (char_cnt encoded_len) { /* something went wrong! */ err = PHP_ICONV_ERR_UNKNOWN; @@ -1480,10 +1483,12 @@ case '\r': case '\n': case ' ': case '\t': { char *decoded_text; size_t decoded_text_len; + int dummy; switch (enc_scheme) { case PHP_ICONV_ENC_SCHEME_BASE64: - decoded_text = (char *)php_base64_decode((unsigned char*)encoded_text, (int)encoded_text_len, decoded_text_len); + decoded_text = (char *)php_base64_decode((unsigned char*)encoded_text, (int)encoded_text_len, dummy); + decoded_text_len = (size_t)dummy; break; case PHP_ICONV_ENC_SCHEME_QPRINT: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/iconv iconv.c /ext/standard quot_print.c quot_print.h
On Tue, 2 Dec 2003, Moriyoshi Koizumi wrote: moriyoshi Tue Dec 2 02:36:43 2003 EDT Modified files: /php-src/ext/standard quot_print.c quot_print.h /php-src/ext/iconviconv.c Log: all '_' (underscores) should be replaced by '\x20' (whitespaces) in encoding. # should I bump API version? Only if you merge it to PHP_4_3 ... 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/iconv iconv.c /ext/standard quot_print.c quot_print.h
On 2003/12/02, at 20:27, Derick Rethans wrote: On Tue, 2 Dec 2003, Moriyoshi Koizumi wrote: # should I bump API version? Only if you merge it to PHP_4_3 ... Okay, so seems I don't need to bump it since that function only exists in HEAD. Moriyoshi Derick -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c /ext/iconv/tests iconv_mime_decode.phpt
moriyoshi Mon Dec 1 16:47:20 2003 EDT Modified files: /php-src/ext/iconv iconv.c /php-src/ext/iconv/testsiconv_mime_decode.phpt Log: More RFC2047 conformance. Add ability to forcefully continue processing on error. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.98 php-src/ext/iconv/iconv.c:1.99 --- php-src/ext/iconv/iconv.c:1.98 Sat Nov 22 08:36:55 2003 +++ php-src/ext/iconv/iconv.c Mon Dec 1 16:47:19 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.98 2003/11/22 13:36:55 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.99 2003/12/01 21:47:19 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -121,6 +121,9 @@ } php_iconv_enc_scheme_t; /* }}} */ +#define PHP_ICONV_MIME_DECODE_STRICT(10) +#define PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR (11) + #ifdef HAVE_LIBICONV #define iconv libiconv #endif @@ -141,7 +144,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fname, size_t fname_nbytes, const char *fval, size_t fval_nbytes, unsigned int max_line_len, const char *lfchars, php_iconv_enc_scheme_t enc_scheme, const char *out_charset, const char *enc); -static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *str, size_t str_nbytes, const char *enc); +static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *str, size_t str_nbytes, const char *enc, int mode); /* }}} */ /* {{{ static globals */ @@ -196,6 +199,9 @@ #endif REGISTER_STRING_CONSTANT(ICONV_VERSION, version, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(ICONV_MIME_DECODE_STRICT, PHP_ICONV_MIME_DECODE_STRICT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(ICONV_MIME_DECODE_CONTINUE_ON_ERROR, PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR, CONST_CS | CONST_PERSISTENT); + return SUCCESS; } /* }}} */ @@ -1167,7 +1173,7 @@ /* }}} */ /* {{{ _php_iconv_mime_decode() */ -static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *str, size_t str_nbytes, const char *enc) +static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *str, size_t str_nbytes, const char *enc, int mode) { php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS; @@ -1180,6 +1186,8 @@ size_t csname_len; const char *encoded_text = NULL; size_t encoded_text_len; + const char *encoded_word = NULL; + const char *spaces = NULL; php_iconv_enc_scheme_t enc_scheme; @@ -1200,6 +1208,7 @@ p1 = str; for (str_left = str_nbytes; str_left 0; str_left--, p1++) { + int eos = 0; switch (scan_stat) { case 0: @@ -1211,20 +1220,45 @@ case '\n': scan_stat = 8; break; - + case '=': + encoded_word = p1; scan_stat = 1; break; - + + case ' ': case '\t': + spaces = p1; + scan_stat = 11; + break; + default: _php_iconv_appendc(pretval, *p1, cd_pl); + encoded_word = NULL; + if ((mode PHP_ICONV_MIME_DECODE_STRICT)) { + scan_stat = 12; + } + break; } break; case 1: if (*p1 != '?') { - err = PHP_ICONV_ERR_MALFORMED; - goto out; + if ((mode PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + if (err != PHP_ICONV_ERR_SUCCESS) { + goto out; + } + encoded_word = NULL; + if ((mode PHP_ICONV_MIME_DECODE_STRICT)) { +
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Mon Dec 1 18:25:06 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Allow iconv_mime_decode_headers() to handle multiple occurence of a header. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.100 php-src/ext/iconv/iconv.c:1.101 --- php-src/ext/iconv/iconv.c:1.100 Mon Dec 1 17:46:44 2003 +++ php-src/ext/iconv/iconv.c Mon Dec 1 18:25:06 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.100 2003/12/01 22:46:44 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.101 2003/12/01 23:25:06 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2051,7 +2051,26 @@ } if (header_name != NULL) { - add_assoc_stringl_ex(return_value, header_name, header_name_len, header_value, header_value_len, 1); + zval **elem; + + if (zend_hash_find(Z_ARRVAL_P(return_value), header_name, header_name_len, (void **)elem) == SUCCESS) { + if (Z_TYPE_PP(elem) != IS_ARRAY) { + zval *new_elem; + + MAKE_STD_ZVAL(new_elem); + array_init(new_elem); + + ZVAL_ADDREF(*elem); + add_next_index_zval(new_elem, *elem); + + zend_hash_update(Z_ARRVAL_P(return_value), header_name, header_name_len, (void *)new_elem, sizeof(new_elem), NULL); + + elem = new_elem; + } + add_next_index_stringl(*elem, header_value, header_value_len, 1); + } else { + add_assoc_stringl_ex(return_value, header_name, header_name_len, header_value, header_value_len, 1); + } } encoded_str_len -= next_pos - encoded_str; encoded_str = next_pos; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Mon Dec 1 18:49:21 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Loosen error check. There's no reason to forbid a single '=' occurrence in an unencoded string. Fix white space handing. Meaningful spaces have got stripped wrongly before this patch. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.101 php-src/ext/iconv/iconv.c:1.102 --- php-src/ext/iconv/iconv.c:1.101 Mon Dec 1 18:25:06 2003 +++ php-src/ext/iconv/iconv.c Mon Dec 1 18:49:20 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.101 2003/12/01 23:25:06 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.102 2003/12/01 23:49:20 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1248,22 +1248,17 @@ case 1: if (*p1 != '?') { - if ((mode PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) { - err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); - if (err != PHP_ICONV_ERR_SUCCESS) { - goto out; - } - encoded_word = NULL; - if ((mode PHP_ICONV_MIME_DECODE_STRICT)) { - scan_stat = 12; - } else { - scan_stat = 0; - } - break; - } else { - err = PHP_ICONV_ERR_MALFORMED; + err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl); + if (err != PHP_ICONV_ERR_SUCCESS) { goto out; } + encoded_word = NULL; + if ((mode PHP_ICONV_MIME_DECODE_STRICT)) { + scan_stat = 12; + } else { + scan_stat = 0; + } + break; } csname = p1 + 1; scan_stat = 2; @@ -1596,6 +1591,8 @@ encoded_word = NULL; if ((mode PHP_ICONV_MIME_DECODE_STRICT)) { scan_stat = 12; + } else { + scan_stat = 0; } break; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Sat Nov 22 08:36:56 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Fixed bug #26194 (iconv() not properly defined with libiconv). # Thank you Steph and Frank! Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.97 php-src/ext/iconv/iconv.c:1.98 --- php-src/ext/iconv/iconv.c:1.97 Sun Nov 2 13:54:08 2003 +++ php-src/ext/iconv/iconv.c Sat Nov 22 08:36:55 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.97 2003/11/02 18:54:08 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.98 2003/11/22 13:36:55 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -51,6 +51,10 @@ #include gnu/libc-version.h #endif +#ifdef HAVE_LIBICONV +#undef iconv +#endif + #include ext/standard/php_smart_str.h #include ext/standard/base64.h #include ext/standard/quot_print.h @@ -117,6 +121,10 @@ } php_iconv_enc_scheme_t; /* }}} */ +#ifdef HAVE_LIBICONV +#define iconv libiconv +#endif + /* {{{ prototypes */ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, iconv_t cd); static php_iconv_err_t _php_iconv_appendc(smart_str *d, const char c, iconv_t cd); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Sun Nov 2 13:54:08 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Proto fix Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.96 php-src/ext/iconv/iconv.c:1.97 --- php-src/ext/iconv/iconv.c:1.96 Wed Aug 13 14:21:06 2003 +++ php-src/ext/iconv/iconv.c Sun Nov 2 13:54:08 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.96 2003/08/13 18:21:06 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.97 2003/11/02 18:54:08 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1510,7 +1510,7 @@ } /* }}} */ -/* {{{ proto string iconv_strpos(string haystack, string needle, int offset [, string charset]) +/* {{{ proto int iconv_strpos(string haystack, string needle, int offset [, string charset]) Finds position of first occurrence of needle within part of haystack beginning with offset */ PHP_FUNCTION(iconv_strpos) { @@ -1552,7 +1552,7 @@ } /* }}} */ -/* {{{ proto string iconv_strrpos(string haystack, string needle [, string charset]) +/* {{{ proto int iconv_strrpos(string haystack, string needle [, string charset]) Finds position of last occurrence of needle within part of haystack beginning with offset */ PHP_FUNCTION(iconv_strrpos) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Wed Aug 13 14:21:07 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Slight improvement. Hope this will make some difference. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.95 php-src/ext/iconv/iconv.c:1.96 --- php-src/ext/iconv/iconv.c:1.95 Tue Aug 12 00:19:06 2003 +++ php-src/ext/iconv/iconv.c Wed Aug 13 14:21:06 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.95 2003/08/12 04:19:06 iliaa Exp $ */ +/* $Id: iconv.c,v 1.96 2003/08/13 18:21:06 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -41,11 +41,11 @@ #ifdef HAVE_ICONV -#ifndef PHP_ICONV_H_PATH -#define PHP_ICONV_H_PATH iconv.h -#endif - +#ifdef PHP_ICONV_H_PATH #include PHP_ICONV_H_PATH +#else +#include iconv.h +#endif #ifdef HAVE_GLIBC_ICONV #include gnu/libc-version.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/iconv iconv.c
That's pretty useless, PHP_ICONV_H_PATH is always set. And it's still wrong.. --Jani On Wed, 13 Aug 2003, Moriyoshi Koizumi wrote: moriyoshi Wed Aug 13 14:21:07 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Slight improvement. Hope this will make some difference. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.95 php-src/ext/iconv/iconv.c:1.96 --- php-src/ext/iconv/iconv.c:1.95 Tue Aug 12 00:19:06 2003 +++ php-src/ext/iconv/iconv.c Wed Aug 13 14:21:06 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.95 2003/08/12 04:19:06 iliaa Exp $ */ +/* $Id: iconv.c,v 1.96 2003/08/13 18:21:06 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -41,11 +41,11 @@ #ifdef HAVE_ICONV -#ifndef PHP_ICONV_H_PATH -#define PHP_ICONV_H_PATH iconv.h -#endif - +#ifdef PHP_ICONV_H_PATH #include PHP_ICONV_H_PATH +#else +#include iconv.h +#endif #ifdef HAVE_GLIBC_ICONV #include gnu/libc-version.h -- https://www.paypal.com/xclick/[EMAIL PROTECTED]no_note=1tax=0currency_code=EUR -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
iliaa Tue Aug 12 00:19:07 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Fix compiler warnings. Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.94 php-src/ext/iconv/iconv.c:1.95 --- php-src/ext/iconv/iconv.c:1.94 Wed Jul 30 17:56:45 2003 +++ php-src/ext/iconv/iconv.c Tue Aug 12 00:19:06 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.94 2003/07/30 21:56:45 sniper Exp $ */ +/* $Id: iconv.c,v 1.95 2003/08/12 04:19:06 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -243,7 +243,7 @@ out_p = (d)-c + (d)-len; - if (iconv(cd, in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { + if (iconv(cd, (char **)in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { #if ICONV_SUPPORTS_ERRNO switch (errno) { case EINVAL: @@ -403,7 +403,7 @@ out_p = out_buf; while (in_left 0) { - result = iconv(cd, (const char **) in_p, in_left, (char **) out_p, out_left); + result = iconv(cd, (char **) in_p, in_left, (char **) out_p, out_left); out_size = bsz - out_left; if (result == (size_t)(-1)) { if (errno == E2BIG in_left 0) { @@ -517,7 +517,7 @@ prev_in_left = in_left; - if (iconv(cd, in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { + if (iconv(cd, (char **)in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { if (prev_in_left == in_left) { break; } @@ -617,7 +617,7 @@ prev_in_left = in_left; - if (iconv(cd1, in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { + if (iconv(cd1, (char **)in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { if (prev_in_left == in_left) { break; } @@ -748,7 +748,7 @@ prev_in_left = in_left; - if (iconv(cd, in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { + if (iconv(cd, (char **)in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { if (prev_in_left == in_left) { #if ICONV_SUPPORTS_ERRNO switch (errno) { @@ -982,7 +982,7 @@ out_left = out_size - out_reserved; - if (iconv(cd, in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { + if (iconv(cd, (char **)in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { #if ICONV_SUPPORTS_ERRNO switch (errno) { case EINVAL: @@ -1070,7 +1070,7 @@ out_p = buf; out_left = out_size = 1; - if (iconv(cd, in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { + if (iconv(cd, (char **)in_p, in_left, (char **) out_p, out_left) == (size_t)-1) { #if ICONV_SUPPORTS_ERRNO switch (errno) { case EINVAL: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Sun Jul 6 17:19:08 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Improved iconv_mime_encode() interface Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.90 php-src/ext/iconv/iconv.c:1.91 --- php-src/ext/iconv/iconv.c:1.90 Sun Jul 6 17:08:50 2003 +++ php-src/ext/iconv/iconv.c Sun Jul 6 17:19:08 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.90 2003/07/06 21:08:50 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.91 2003/07/06 21:19:08 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1587,7 +1587,7 @@ } /* }}} */ -/* {{{ proto string iconv_mime_encode(string field_name, string field_value, string scheme, string out_charset [, string in_charset, int line_len, string lfchars]) +/* {{{ proto string iconv_mime_encode(string field_name, string field_value, [, array preference]) Composes a mime header field with field_name and field_value in a specified scheme */ PHP_FUNCTION(iconv_mime_encode) { @@ -1595,16 +1595,13 @@ int field_name_len; char *field_value; int field_value_len; - char *scheme; - int scheme_len; + zval *pref; + zval val, *pval, **ppval; char *in_charset; - int in_charset_len; char *out_charset; - int out_charset_len; long line_len = 76; char *lfchars = \r\n; - int lfchars_len = sizeof(\r\n)-1; - + php_iconv_enc_scheme_t scheme_id = PHP_ICONV_ENC_SCHEME_BASE64; smart_str retval = {0}; @@ -1613,23 +1610,72 @@ in_charset = ICONVG(internal_encoding); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |sls, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|a, field_name, field_name_len, field_value, field_value_len, - scheme, scheme_len, out_charset, out_charset_len, - in_charset, in_charset_len, line_len, lfchars, lfchars_len) == FAILURE) { + pref) == FAILURE) { RETURN_FALSE; } - if (scheme_len 0) { - switch (scheme[0]) { - case 'B': case 'b': - scheme_id = PHP_ICONV_ENC_SCHEME_BASE64; - break; + if (zend_hash_find(Z_ARRVAL_P(pref), scheme, sizeof(scheme), (void **)ppval) == SUCCESS) { + if (Z_TYPE_PP(ppval) == IS_STRING Z_STRLEN_PP(ppval) 0) { + switch (Z_STRVAL_PP(ppval)[0]) { + case 'B': case 'b': + scheme_id = PHP_ICONV_ENC_SCHEME_BASE64; + break; - case 'Q': case 'q': - scheme_id = PHP_ICONV_ENC_SCHEME_QPRINT; - break; + case 'Q': case 'q': + scheme_id = PHP_ICONV_ENC_SCHEME_QPRINT; + break; + } + } + } + + if (zend_hash_find(Z_ARRVAL_P(pref), input-charset, sizeof(input-charset), (void **)ppval) == SUCCESS) { + if (Z_TYPE_PP(ppval) == IS_STRING Z_STRLEN_PP(ppval) 0) { + in_charset = Z_STRVAL_PP(ppval); + } else { + in_charset = ICONVG(internal_encoding); + } + } + + if (zend_hash_find(Z_ARRVAL_P(pref), output-charset, sizeof(output-charset), (void **)ppval) == SUCCESS) { + if (Z_TYPE_PP(ppval) == IS_STRING Z_STRLEN_PP(ppval) 0) { + out_charset = Z_STRVAL_PP(ppval); + } else { + out_charset = in_charset; + } + } + + if (zend_hash_find(Z_ARRVAL_P(pref), line-length, sizeof(line-length), (void **)ppval) == SUCCESS) { + pval = *ppval; + if (Z_TYPE_P(pval) != IS_LONG) { + val = *pval; + zval_copy_ctor(val); + convert_to_long(val); + pval = val; + } + + line_len = Z_LVAL_P(pval); + + if (pval == val) { + zval_dtor(val); + } + } + + if (zend_hash_find(Z_ARRVAL_P(pref), line-break-chars, sizeof(line-break-chars), (void **)ppval) == SUCCESS) { + pval = *ppval; + if (Z_TYPE_P(pval) != IS_STRING) { + val = *pval; + zval_copy_ctor(val); + convert_to_string(val); + pval = val; + } + + lfchars = Z_STRVAL_P(pval); + + if (pval == val) { + zval_dtor(val); } } -- PHP CVS Mailing
[PHP-CVS] cvs: php-src /ext/iconv iconv.c
moriyoshi Sun Jul 6 17:30:23 2003 EDT Modified files: /php-src/ext/iconv iconv.c Log: Fixed segfault due to reference to the already free'd block :) Index: php-src/ext/iconv/iconv.c diff -u php-src/ext/iconv/iconv.c:1.91 php-src/ext/iconv/iconv.c:1.92 --- php-src/ext/iconv/iconv.c:1.91 Sun Jul 6 17:19:08 2003 +++ php-src/ext/iconv/iconv.c Sun Jul 6 17:30:23 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: iconv.c,v 1.91 2003/07/06 21:19:08 moriyoshi Exp $ */ +/* $Id: iconv.c,v 1.92 2003/07/06 21:30:23 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1600,7 +1600,7 @@ char *in_charset; char *out_charset; long line_len = 76; - char *lfchars = \r\n; + zval lfchars; php_iconv_enc_scheme_t scheme_id = PHP_ICONV_ENC_SCHEME_BASE64; @@ -1664,23 +1664,18 @@ } if (zend_hash_find(Z_ARRVAL_P(pref), line-break-chars, sizeof(line-break-chars), (void **)ppval) == SUCCESS) { - pval = *ppval; - if (Z_TYPE_P(pval) != IS_STRING) { - val = *pval; - zval_copy_ctor(val); - convert_to_string(val); - pval = val; - } + lfchars = **ppval; + zval_copy_ctor(lfchars); - lfchars = Z_STRVAL_P(pval); - - if (pval == val) { - zval_dtor(val); + if (Z_TYPE(lfchars) != IS_STRING) { + convert_to_string(lfchars); } + } else { + ZVAL_STRING(lfchars, \r\n, 1); } err = _php_iconv_mime_encode(retval, field_name, field_name_len, - field_value, field_value_len, line_len, lfchars, scheme_id, + field_value, field_value_len, line_len, Z_STRVAL(lfchars), scheme_id, out_charset, in_charset); _php_iconv_show_error(err, out_charset, in_charset TSRMLS_CC); @@ -1694,6 +1689,8 @@ smart_str_free(retval); RETVAL_FALSE; } + + zval_dtor(lfchars); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php