Diff for /embedaddon/php/ext/iconv/iconv.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2012/05/29 12:34:39 version 1.1.1.3, 2013/07/22 01:31:52
Line 2 Line 2
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | PHP Version 5                                                        |     | PHP Version 5                                                        |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
   | Copyright (c) 1997-2012 The PHP Group                                |   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |     | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |     | that is bundled with this package in the file LICENSE, and is        |
Line 190  typedef enum _php_iconv_enc_scheme_t { Line 190  typedef enum _php_iconv_enc_scheme_t {
 #define PHP_ICONV_MIME_DECODE_STRICT            (1<<0)  #define PHP_ICONV_MIME_DECODE_STRICT            (1<<0)
 #define PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR (1<<1)  #define PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR (1<<1)
   
/* {{{ prototypes */ /* {{{ 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_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_appendc(smart_str *d, const char c, iconv_t cd);
   
Line 249  PHP_MINIT_FUNCTION(miconv) Line 249  PHP_MINIT_FUNCTION(miconv)
         {          {
                 static char buf[16];                  static char buf[16];
                 snprintf(buf, sizeof(buf), "%d.%d",                  snprintf(buf, sizeof(buf), "%d.%d",
                    ((_libiconv_version >> 8) & 0x0f), (_libiconv_version & 0x0f));                     ((_libiconv_version >> 8) & 0x0f), (_libiconv_version & 0x0f));
                 version = buf;                  version = buf;
         }          }
 #elif HAVE_GLIBC_ICONV  #elif HAVE_GLIBC_ICONV
Line 354  static int php_iconv_output_handler(void **nothing, ph Line 354  static int php_iconv_output_handler(void **nothing, ph
   
                 if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {                  if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
                         int len;                          int len;
                        char *p = strstr(ICONVG(output_encoding), "//");                         char *p = strstr(ICONVG(output_encoding), "//");
   
                         if (p) {                          if (p) {
                                 len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, (int)(p - ICONVG(output_encoding)), ICONVG(output_encoding));                                  len = spprintf(&content_type, 0, "Content-Type:%.*s; charset=%.*s", mimetype_len ? mimetype_len : (int) strlen(mimetype), mimetype, (int)(p - ICONVG(output_encoding)), ICONVG(output_encoding));
Line 375  static int php_iconv_output_handler(void **nothing, ph Line 375  static int php_iconv_output_handler(void **nothing, ph
   
         return SUCCESS;          return SUCCESS;
 }  }
       
 /* {{{ _php_iconv_appendl() */  /* {{{ _php_iconv_appendl() */
 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_appendl(smart_str *d, const char *s, size_t l, iconv_t cd)
 {  {
Line 400  static php_iconv_err_t _php_iconv_appendl(smart_str *d Line 400  static php_iconv_err_t _php_iconv_appendl(smart_str *d
   
                         if (iconv(cd, (char **)&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  #if ICONV_SUPPORTS_ERRNO
                                switch (errno) {                                 switch (errno) {
                                         case EINVAL:                                          case EINVAL:
                                                 return PHP_ICONV_ERR_ILLEGAL_CHAR;                                                  return PHP_ICONV_ERR_ILLEGAL_CHAR;
   
Line 415  static php_iconv_err_t _php_iconv_appendl(smart_str *d Line 415  static php_iconv_err_t _php_iconv_appendl(smart_str *d
                                 }                                  }
 #else  #else
                                 if (prev_in_left == in_left) {                                  if (prev_in_left == in_left) {
                                        return PHP_ICONV_ERR_UNKNOWN;                                                   return PHP_ICONV_ERR_UNKNOWN;
                                 }                                  }
 #endif  #endif
                         }                          }
Line 446  static php_iconv_err_t _php_iconv_appendl(smart_str *d Line 446  static php_iconv_err_t _php_iconv_appendl(smart_str *d
 #else  #else
                                 if (out_left != 0) {                                  if (out_left != 0) {
                                         return PHP_ICONV_ERR_UNKNOWN;                                          return PHP_ICONV_ERR_UNKNOWN;
                                }                                       }
 #endif  #endif
                         }                          }
                         (d)->len += (buf_growth - out_left);                          (d)->len += (buf_growth - out_left);
Line 492  PHP_ICONV_API php_iconv_err_t php_iconv_string(const c Line 492  PHP_ICONV_API php_iconv_err_t php_iconv_string(const c
         in_size = in_len;          in_size = in_len;
   
         cd = iconv_open(out_charset, in_charset);          cd = iconv_open(out_charset, in_charset);
        
         if (cd == (iconv_t)(-1)) {          if (cd == (iconv_t)(-1)) {
                 return PHP_ICONV_ERR_UNKNOWN;                  return PHP_ICONV_ERR_UNKNOWN;
         }          }
   
         out_buffer = (char *) emalloc(out_size + 1);          out_buffer = (char *) emalloc(out_size + 1);
         out_p = out_buffer;          out_p = out_buffer;
        
 #ifdef NETWARE  #ifdef NETWARE
         result = iconv(cd, (char **) &in_p, &in_size, (char **)          result = iconv(cd, (char **) &in_p, &in_size, (char **)
 #else  #else
         result = iconv(cd, (const char **) &in_p, &in_size, (char **)          result = iconv(cd, (const char **) &in_p, &in_size, (char **)
 #endif  #endif
                                 &out_p, &out_left);                                  &out_p, &out_left);
        
         if (result == (size_t)(-1)) {          if (result == (size_t)(-1)) {
                 efree(out_buffer);                  efree(out_buffer);
                 return PHP_ICONV_ERR_UNKNOWN;                  return PHP_ICONV_ERR_UNKNOWN;
         }          }
   
         if (out_left < 8) {          if (out_left < 8) {
                out_buffer = (char *) erealloc(out_buffer, out_size + 8);                size_t pos = out_p - out_buffer;
                 out_buffer = (char *) safe_erealloc(out_buffer, out_size, 1, 8);
                 out_p = out_buffer+pos;
                 out_size += 7;
                 out_left += 7;
         }          }
   
        /* flush the shift-out sequences */         /* flush the shift-out sequences */
         result = iconv(cd, NULL, NULL, &out_p, &out_left);          result = iconv(cd, NULL, NULL, &out_p, &out_left);
   
         if (result == (size_t)(-1)) {          if (result == (size_t)(-1)) {
Line 555  PHP_ICONV_API php_iconv_err_t php_iconv_string(const c Line 559  PHP_ICONV_API php_iconv_err_t php_iconv_string(const c
                 }                  }
         }          }
         in_left= in_len;          in_left= in_len;
        out_left = in_len + 32; /* Avoid realloc() most cases */         out_left = in_len + 32; /* Avoid realloc() most cases */
         out_size = 0;          out_size = 0;
         bsz = out_left;          bsz = out_left;
        out_buf = (char *) emalloc(bsz+1);         out_buf = (char *) emalloc(bsz+1);
         out_p = out_buf;          out_p = out_buf;
   
         while (in_left > 0) {          while (in_left > 0) {
Line 573  PHP_ICONV_API php_iconv_err_t php_iconv_string(const c Line 577  PHP_ICONV_API php_iconv_err_t php_iconv_string(const c
                                 out_p = out_buf = tmp_buf;                                  out_p = out_buf = tmp_buf;
                                 out_p += out_size;                                  out_p += out_size;
                                 out_left = bsz - out_size;                                  out_left = bsz - out_size;
                                continue;                                       continue;
                         }                          }
                 }                  }
                 break;                  break;
         }          }
   
         if (result != (size_t)(-1)) {          if (result != (size_t)(-1)) {
                /* flush the shift-out sequences */                 /* flush the shift-out sequences */
                 for (;;) {                  for (;;) {
                         result = iconv(cd, NULL, NULL, (char **) &out_p, &out_left);                          result = iconv(cd, NULL, NULL, (char **) &out_p, &out_left);
                         out_size = bsz - out_left;                          out_size = bsz - out_left;
Line 592  PHP_ICONV_API php_iconv_err_t php_iconv_string(const c Line 596  PHP_ICONV_API php_iconv_err_t php_iconv_string(const c
                         if (errno == E2BIG) {                          if (errno == E2BIG) {
                                 bsz += 16;                                  bsz += 16;
                                 tmp_buf = (char *) erealloc(out_buf, bsz);                                  tmp_buf = (char *) erealloc(out_buf, bsz);
                                
                                 out_p = out_buf = tmp_buf;                                  out_p = out_buf = tmp_buf;
                                 out_p += out_size;                                  out_p += out_size;
                                 out_left = bsz - out_size;                                  out_left = bsz - out_size;
Line 684  static php_iconv_err_t _php_iconv_strlen(unsigned int  Line 688  static php_iconv_err_t _php_iconv_strlen(unsigned int 
         }          }
   
         if (out_left > 0) {          if (out_left > 0) {
                cnt -= out_left / GENERIC_SUPERSET_NBYTES;                 cnt -= out_left / GENERIC_SUPERSET_NBYTES;
         }          }
   
 #if ICONV_SUPPORTS_ERRNO  #if ICONV_SUPPORTS_ERRNO
Line 735  static php_iconv_err_t _php_iconv_substr(smart_str *pr Line 739  static php_iconv_err_t _php_iconv_substr(smart_str *pr
   
         unsigned int cnt;          unsigned int cnt;
         int total_len;          int total_len;
        
         err = _php_iconv_strlen(&total_len, str, nbytes, enc);          err = _php_iconv_strlen(&total_len, str, nbytes, enc);
         if (err != PHP_ICONV_ERR_SUCCESS) {          if (err != PHP_ICONV_ERR_SUCCESS) {
                 return err;                  return err;
         }          }
        
         if (len < 0) {          if (len < 0) {
                 if ((len += (total_len - offset)) < 0) {                  if ((len += (total_len - offset)) < 0) {
                         return PHP_ICONV_ERR_SUCCESS;                          return PHP_ICONV_ERR_SUCCESS;
Line 772  static php_iconv_err_t _php_iconv_substr(smart_str *pr Line 776  static php_iconv_err_t _php_iconv_substr(smart_str *pr
                 smart_str_0(pretval);                  smart_str_0(pretval);
                 return PHP_ICONV_ERR_SUCCESS;                  return PHP_ICONV_ERR_SUCCESS;
         }          }
        
         cd1 = iconv_open(GENERIC_SUPERSET_NAME, enc);          cd1 = iconv_open(GENERIC_SUPERSET_NAME, enc);
   
         if (cd1 == (iconv_t)(-1)) {          if (cd1 == (iconv_t)(-1)) {
Line 857  static php_iconv_err_t _php_iconv_substr(smart_str *pr Line 861  static php_iconv_err_t _php_iconv_substr(smart_str *pr
   
         if (cd2 != (iconv_t)NULL) {          if (cd2 != (iconv_t)NULL) {
                 iconv_close(cd2);                  iconv_close(cd2);
        }               }
         return err;          return err;
 }  }
   
Line 1042  static php_iconv_err_t _php_iconv_strpos(unsigned int  Line 1046  static php_iconv_err_t _php_iconv_strpos(unsigned int 
         if (ndl_buf) {          if (ndl_buf) {
                 efree(ndl_buf);                  efree(ndl_buf);
         }          }
        
         iconv_close(cd);          iconv_close(cd);
   
         return err;          return err;
Line 1089  static php_iconv_err_t _php_iconv_mime_encode(smart_st Line 1093  static php_iconv_err_t _php_iconv_mime_encode(smart_st
         if ((fname_nbytes + 2) >= max_line_len          if ((fname_nbytes + 2) >= max_line_len
                 || (out_charset_len + 12) >= max_line_len) {                  || (out_charset_len + 12) >= max_line_len) {
                 /* field name is too long */                  /* field name is too long */
                err = PHP_ICONV_ERR_TOO_BIG;                 err = PHP_ICONV_ERR_TOO_BIG;
                 goto out;                  goto out;
         }          }
   
Line 1131  static php_iconv_err_t _php_iconv_mime_encode(smart_st Line 1135  static php_iconv_err_t _php_iconv_mime_encode(smart_st
         char_cnt -= 2;          char_cnt -= 2;
   
         in_p = fval;          in_p = fval;
        in_left = fval_nbytes;         in_left = fval_nbytes;
   
         do {          do {
                 size_t prev_in_left;                  size_t prev_in_left;
Line 1142  static php_iconv_err_t _php_iconv_mime_encode(smart_st Line 1146  static php_iconv_err_t _php_iconv_mime_encode(smart_st
                         smart_str_appendl(pretval, lfchars, lfchars_len);                          smart_str_appendl(pretval, lfchars, lfchars_len);
                         smart_str_appendc(pretval, ' ');                          smart_str_appendc(pretval, ' ');
                         char_cnt = max_line_len - 1;                          char_cnt = max_line_len - 1;
                }                 }
 
                 smart_str_appendl(pretval, "=?", sizeof("=?") - 1);                  smart_str_appendl(pretval, "=?", sizeof("=?") - 1);
                 char_cnt -= 2;                  char_cnt -= 2;
                 smart_str_appendl(pretval, out_charset, out_charset_len);                  smart_str_appendl(pretval, out_charset, out_charset_len);
Line 1195  static php_iconv_err_t _php_iconv_mime_encode(smart_st Line 1199  static php_iconv_err_t _php_iconv_mime_encode(smart_st
                                                                         goto out;                                                                          goto out;
                                                                 }                                                                  }
                                                                 break;                                                                  break;
        
                                                         default:                                                          default:
                                                                 err = PHP_ICONV_ERR_UNKNOWN;                                                                  err = PHP_ICONV_ERR_UNKNOWN;
                                                                 goto out;                                                                  goto out;
Line 1295  static php_iconv_err_t _php_iconv_mime_encode(smart_st Line 1299  static php_iconv_err_t _php_iconv_mime_encode(smart_st
                                                                         goto out;                                                                          goto out;
                                                                 }                                                                  }
                                                                 break;                                                                  break;
        
                                                         default:                                                          default:
                                                                 err = PHP_ICONV_ERR_UNKNOWN;                                                                  err = PHP_ICONV_ERR_UNKNOWN;
                                                                 goto out;                                                                  goto out;
Line 1372  out: Line 1376  out:
         }          }
         if (encoded != NULL) {          if (encoded != NULL) {
                 efree(encoded);                  efree(encoded);
        }               }
         if (buf != NULL) {          if (buf != NULL) {
                 efree(buf);                  efree(buf);
         }          }
Line 1391  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1395  static php_iconv_err_t _php_iconv_mime_decode(smart_st
         size_t str_left;          size_t str_left;
         unsigned int scan_stat = 0;          unsigned int scan_stat = 0;
         const char *csname = NULL;          const char *csname = NULL;
        size_t csname_len;         size_t csname_len;
         const char *encoded_text = NULL;          const char *encoded_text = NULL;
         size_t encoded_text_len = 0;          size_t encoded_text_len = 0;
         const char *encoded_word = NULL;          const char *encoded_word = NULL;
Line 1430  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1434  static php_iconv_err_t _php_iconv_mime_decode(smart_st
                                                 break;                                                  break;
   
                                         case '\n':                                          case '\n':
                                                scan_stat = 8;                                                  scan_stat = 8;
                                                 break;                                                  break;
   
                                         case '=': /* first letter of an encoded chunk */                                          case '=': /* first letter of an encoded chunk */
Line 1455  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1459  static php_iconv_err_t _php_iconv_mime_decode(smart_st
   
                         case 1: /* expecting a delimiter */                          case 1: /* expecting a delimiter */
                                 if (*p1 != '?') {                                  if (*p1 != '?') {
                                        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 + 1) - encoded_word), cd_pl);
                                         if (err != PHP_ICONV_ERR_SUCCESS) {                                          if (err != PHP_ICONV_ERR_SUCCESS) {
                                                 goto out;                                                  goto out;
                                         }                                          }
Line 1470  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1474  static php_iconv_err_t _php_iconv_mime_decode(smart_st
                                 csname = p1 + 1;                                  csname = p1 + 1;
                                 scan_stat = 2;                                  scan_stat = 2;
                                 break;                                  break;
                        
                         case 2: /* expecting a charset name */                          case 2: /* expecting a charset name */
                                 switch (*p1) {                                  switch (*p1) {
                                         case '?': /* normal delimiter: encoding scheme follows */                                          case '?': /* normal delimiter: encoding scheme follows */
Line 1480  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1484  static php_iconv_err_t _php_iconv_mime_decode(smart_st
                                         case '*': /* new style delimiter: locale id follows */                                          case '*': /* new style delimiter: locale id follows */
                                                 scan_stat = 10;                                                  scan_stat = 10;
                                                 break;                                                  break;
                                }                                 }
                                 if (scan_stat != 2) {                                  if (scan_stat != 2) {
                                         char tmpbuf[80];                                          char tmpbuf[80];
   
Line 1493  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1497  static php_iconv_err_t _php_iconv_mime_decode(smart_st
   
                                         if (csname_len > sizeof(tmpbuf) - 1) {                                          if (csname_len > sizeof(tmpbuf) - 1) {
                                                 if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {                                                  if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {
                                                        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 + 1) - encoded_word), cd_pl);
                                                         if (err != PHP_ICONV_ERR_SUCCESS) {                                                          if (err != PHP_ICONV_ERR_SUCCESS) {
                                                                 goto out;                                                                  goto out;
                                                         }                                                          }
Line 1549  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1553  static php_iconv_err_t _php_iconv_mime_decode(smart_st
                                                                 --str_left;                                                                  --str_left;
                                                         }                                                          }
   
                                                        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 + 1) - encoded_word), cd_pl);
                                                         if (err != PHP_ICONV_ERR_SUCCESS) {                                                          if (err != PHP_ICONV_ERR_SUCCESS) {
                                                                 goto out;                                                                  goto out;
                                                         }                                                          }
Line 1608  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1612  static php_iconv_err_t _php_iconv_mime_decode(smart_st
                                                 }                                                  }
                                 }                                  }
                                 break;                                  break;
                
                         case 4: /* expecting a delimiter */                          case 4: /* expecting a delimiter */
                                 if (*p1 != '?') {                                  if (*p1 != '?') {
                                         if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {                                          if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {
                                                 /* pass the entire chunk through the converter */                                                  /* 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 + 1) - encoded_word), cd_pl);
                                                 if (err != PHP_ICONV_ERR_SUCCESS) {                                                  if (err != PHP_ICONV_ERR_SUCCESS) {
                                                         goto out;                                                          goto out;
                                                 }                                                  }
Line 1669  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1673  static php_iconv_err_t _php_iconv_mime_decode(smart_st
                                 if (*p1 != '=') {                                  if (*p1 != '=') {
                                         if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {                                          if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {
                                                 /* pass the entire chunk through the converter */                                                  /* 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 + 1) - encoded_word), cd_pl);
                                                 if (err != PHP_ICONV_ERR_SUCCESS) {                                                  if (err != PHP_ICONV_ERR_SUCCESS) {
                                                         goto out;                                                          goto out;
                                                 }                                                  }
Line 1696  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1700  static php_iconv_err_t _php_iconv_mime_decode(smart_st
                                 switch (*p1) {                                  switch (*p1) {
                                         default:                                          default:
                                                 /* Handle non-RFC-compliant formats                                                  /* Handle non-RFC-compliant formats
                                                 *                                                  *
                                                  * RFC2047 requires the character that comes right                                                   * RFC2047 requires the character that comes right
                                                  * after an encoded word (chunk) to be a whitespace,                                                   * after an encoded word (chunk) to be a whitespace,
                                                  * while there are lots of broken implementations that                                                   * while there are lots of broken implementations that
                                                  * generate such malformed headers that don't fulfill                                                   * generate such malformed headers that don't fulfill
                                                  * that requirement.                                                   * that requirement.
                                                 */                                                  */
                                                if (!eos) {                                                 if (!eos) {
                                                         if ((mode & PHP_ICONV_MIME_DECODE_STRICT)) {                                                          if ((mode & PHP_ICONV_MIME_DECODE_STRICT)) {
                                                                 /* pass the entire chunk through the converter */                                                                  /* 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 + 1) - encoded_word), cd_pl);
                                                                 if (err != PHP_ICONV_ERR_SUCCESS) {                                                                  if (err != PHP_ICONV_ERR_SUCCESS) {
                                                                         goto out;                                                                          goto out;
                                                                 }                                                                  }
Line 1738  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1742  static php_iconv_err_t _php_iconv_mime_decode(smart_st
                                                 if (decoded_text == NULL) {                                                  if (decoded_text == NULL) {
                                                         if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {                                                          if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {
                                                                 /* pass the entire chunk through the converter */                                                                  /* 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 + 1) - encoded_word), cd_pl);
                                                                 if (err != PHP_ICONV_ERR_SUCCESS) {                                                                  if (err != PHP_ICONV_ERR_SUCCESS) {
                                                                         goto out;                                                                          goto out;
                                                                 }                                                                  }
Line 1761  static php_iconv_err_t _php_iconv_mime_decode(smart_st Line 1765  static php_iconv_err_t _php_iconv_mime_decode(smart_st
                                                 if (err != PHP_ICONV_ERR_SUCCESS) {                                                  if (err != PHP_ICONV_ERR_SUCCESS) {
                                                         if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {                                                          if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {
                                                                 /* pass the entire chunk through the converter */                                                                  /* pass the entire chunk through the converter */
                                                                err = _php_iconv_appendl(pretval, encoded_word, (size_t)(p1 - encoded_word), cd_pl);                                                                 err = _php_iconv_appendl(pretval, encoded_word, (size_t)(p1 - encoded_word), cd_pl);
                                                                 encoded_word = NULL;                                                                  encoded_word = NULL;
                                                                 if (err != PHP_ICONV_ERR_SUCCESS) {                                                                  if (err != PHP_ICONV_ERR_SUCCESS) {
                                                                         break;                                                                          break;
Line 1956  PHP_FUNCTION(iconv_strlen) Line 1960  PHP_FUNCTION(iconv_strlen)
         char *charset = ICONVG(internal_encoding);          char *charset = ICONVG(internal_encoding);
         int charset_len = 0;          int charset_len = 0;
         char *str;          char *str;
        int str_len;         int str_len;
   
         php_iconv_err_t err;          php_iconv_err_t err;
   
Line 1972  PHP_FUNCTION(iconv_strlen) Line 1976  PHP_FUNCTION(iconv_strlen)
                 RETURN_FALSE;                  RETURN_FALSE;
         }          }
   
        err = _php_iconv_strlen(&retval, str, str_len, charset);         err = _php_iconv_strlen(&retval, str, str_len, charset);
         _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);          _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);
         if (err == PHP_ICONV_ERR_SUCCESS) {          if (err == PHP_ICONV_ERR_SUCCESS) {
                 RETVAL_LONG(retval);                  RETVAL_LONG(retval);
Line 1989  PHP_FUNCTION(iconv_substr) Line 1993  PHP_FUNCTION(iconv_substr)
         char *charset = ICONVG(internal_encoding);          char *charset = ICONVG(internal_encoding);
         int charset_len = 0;          int charset_len = 0;
         char *str;          char *str;
        int str_len;         int str_len;
         long offset, length = 0;          long offset, length = 0;
   
         php_iconv_err_t err;          php_iconv_err_t err;
Line 2008  PHP_FUNCTION(iconv_substr) Line 2012  PHP_FUNCTION(iconv_substr)
         }          }
   
         if (ZEND_NUM_ARGS() < 3) {          if (ZEND_NUM_ARGS() < 3) {
                length = str_len;                 length = str_len;
         }          }
   
        err = _php_iconv_substr(&retval, str, str_len, offset, length, charset);         err = _php_iconv_substr(&retval, str, str_len, offset, length, charset);
         _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);          _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);
   
         if (err == PHP_ICONV_ERR_SUCCESS && str != NULL && retval.c != NULL) {          if (err == PHP_ICONV_ERR_SUCCESS && str != NULL && retval.c != NULL) {
Line 2029  PHP_FUNCTION(iconv_strpos) Line 2033  PHP_FUNCTION(iconv_strpos)
         char *charset = ICONVG(internal_encoding);          char *charset = ICONVG(internal_encoding);
         int charset_len = 0;          int charset_len = 0;
         char *haystk;          char *haystk;
        int haystk_len;         int haystk_len;
         char *ndl;          char *ndl;
         int ndl_len;          int ndl_len;
         long offset = 0;          long offset = 0;
Line 2059  PHP_FUNCTION(iconv_strpos) Line 2063  PHP_FUNCTION(iconv_strpos)
         }          }
   
         err = _php_iconv_strpos(&retval, haystk, haystk_len, ndl, ndl_len,          err = _php_iconv_strpos(&retval, haystk, haystk_len, ndl, ndl_len,
                                offset, charset);                                 offset, charset);
         _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);          _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);
   
         if (err == PHP_ICONV_ERR_SUCCESS && retval != (unsigned int)-1) {          if (err == PHP_ICONV_ERR_SUCCESS && retval != (unsigned int)-1) {
Line 2077  PHP_FUNCTION(iconv_strrpos) Line 2081  PHP_FUNCTION(iconv_strrpos)
         char *charset = ICONVG(internal_encoding);          char *charset = ICONVG(internal_encoding);
         int charset_len = 0;          int charset_len = 0;
         char *haystk;          char *haystk;
        int haystk_len;         int haystk_len;
         char *ndl;          char *ndl;
         int ndl_len;          int ndl_len;
   
Line 2101  PHP_FUNCTION(iconv_strrpos) Line 2105  PHP_FUNCTION(iconv_strrpos)
         }          }
   
         err = _php_iconv_strpos(&retval, haystk, haystk_len, ndl, ndl_len,          err = _php_iconv_strpos(&retval, haystk, haystk_len, ndl, ndl_len,
                                -1, charset);                                 -1, charset);
         _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);          _php_iconv_show_error(err, GENERIC_SUPERSET_NAME, charset TSRMLS_CC);
   
         if (err == PHP_ICONV_ERR_SUCCESS && retval != (unsigned int)-1) {          if (err == PHP_ICONV_ERR_SUCCESS && retval != (unsigned int)-1) {
Line 2241  PHP_FUNCTION(iconv_mime_decode) Line 2245  PHP_FUNCTION(iconv_mime_decode)
         char *charset = ICONVG(internal_encoding);          char *charset = ICONVG(internal_encoding);
         int charset_len = 0;          int charset_len = 0;
         long mode = 0;          long mode = 0;
        
         smart_str retval = {0};          smart_str retval = {0};
   
         php_iconv_err_t err;          php_iconv_err_t err;
Line 2282  PHP_FUNCTION(iconv_mime_decode_headers) Line 2286  PHP_FUNCTION(iconv_mime_decode_headers)
         char *charset = ICONVG(internal_encoding);          char *charset = ICONVG(internal_encoding);
         int charset_len = 0;          int charset_len = 0;
         long mode = 0;          long mode = 0;
        
         php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;          php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
   
         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",          if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
Line 2350  PHP_FUNCTION(iconv_mime_decode_headers) Line 2354  PHP_FUNCTION(iconv_mime_decode_headers)
                                         zend_hash_update(Z_ARRVAL_P(return_value), header_name, header_name_len, (void *)&new_elem, sizeof(new_elem), NULL);                                          zend_hash_update(Z_ARRVAL_P(return_value), header_name, header_name_len, (void *)&new_elem, sizeof(new_elem), NULL);
   
                                         elem = &new_elem;                                          elem = &new_elem;
                                }                                       }
                                 add_next_index_stringl(*elem, header_value, header_value_len, 1);                                  add_next_index_stringl(*elem, header_value, header_value_len, 1);
                         } else {                          } else {
                                 add_assoc_stringl_ex(return_value, header_name, header_name_len, header_value, header_value_len, 1);                                  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_len -= next_pos - encoded_str;
                encoded_str = next_pos;                 encoded_str = next_pos;
   
                 smart_str_free(&decoded_header);                  smart_str_free(&decoded_header);
         }          }
Line 2378  PHP_NAMED_FUNCTION(php_if_iconv) Line 2382  PHP_NAMED_FUNCTION(php_if_iconv)
         size_t out_len;          size_t out_len;
         int in_charset_len = 0, out_charset_len = 0, in_buffer_len;          int in_charset_len = 0, out_charset_len = 0, in_buffer_len;
         php_iconv_err_t err;          php_iconv_err_t err;
        
         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",          if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
                 &in_charset, &in_charset_len, &out_charset, &out_charset_len, &in_buffer, &in_buffer_len) == FAILURE)                  &in_charset, &in_charset_len, &out_charset, &out_charset_len, &in_buffer, &in_buffer_len) == FAILURE)
                 return;                  return;
Line 2390  PHP_NAMED_FUNCTION(php_if_iconv) Line 2394  PHP_NAMED_FUNCTION(php_if_iconv)
   
         err = php_iconv_string(in_buffer, (size_t)in_buffer_len,          err = php_iconv_string(in_buffer, (size_t)in_buffer_len,
                 &out_buffer, &out_len, out_charset, in_charset);                  &out_buffer, &out_len, out_charset, in_charset);
        _php_iconv_show_error(err, out_charset, in_charset TSRMLS_CC);         _php_iconv_show_error(err, out_charset, in_charset TSRMLS_CC);
         if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {          if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
                 RETVAL_STRINGL(out_buffer, out_len, 0);                  RETVAL_STRINGL(out_buffer, out_len, 0);
         } else {          } else {
Line 2539  static int php_iconv_stream_filter_append_bucket( Line 2543  static int php_iconv_stream_filter_append_bucket(
                 icnt = buf_len;                  icnt = buf_len;
         }          }
   
        out_buf_size = ocnt = prev_ocnt = initial_out_buf_size;         out_buf_size = ocnt = prev_ocnt = initial_out_buf_size;
         if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) {          if (NULL == (out_buf = pemalloc(out_buf_size, persistent))) {
                 return FAILURE;                  return FAILURE;
         }          }

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>