@@ -4168,7 +4168,7 @@ PHP_FUNCTION(mb_send_mail)
4168
4168
int cnt_trans_enc :1 ;
4169
4169
} suppressed_hdrs = { 0 , 0 };
4170
4170
4171
- char * message_buf = NULL , * subject_buf = NULL , * p ;
4171
+ char * subject_buf = NULL , * p ;
4172
4172
mbfl_string orig_str , conv_str ;
4173
4173
mbfl_string * pstr ; /* pointer to mbfl string for return value */
4174
4174
enum mbfl_no_encoding ;
@@ -4326,27 +4326,17 @@ PHP_FUNCTION(mb_send_mail)
4326
4326
}
4327
4327
4328
4328
/* message body */
4329
- orig_str .val = (unsigned char * )message ;
4330
- orig_str .len = message_len ;
4331
- orig_str .encoding = MBSTRG (current_internal_encoding );
4329
+ const mbfl_encoding * msg_enc = MBSTRG (current_internal_encoding );
4332
4330
4333
- if (orig_str . encoding -> no_encoding == mbfl_no_encoding_invalid || orig_str . encoding -> no_encoding == mbfl_no_encoding_pass ) {
4334
- orig_str . encoding = mb_guess_encoding ((unsigned char * )message , message_len , MBSTRG (current_detect_order_list ), MBSTRG (current_detect_order_list_size ), MBSTRG (strict_detection ));
4331
+ if (msg_enc == & mbfl_encoding_pass ) {
4332
+ msg_enc = mb_guess_encoding ((unsigned char * )message , message_len , MBSTRG (current_detect_order_list ), MBSTRG (current_detect_order_list_size ), MBSTRG (strict_detection ));
4335
4333
}
4336
4334
4337
- pstr = NULL ;
4338
- {
4339
- mbfl_string tmpstr ;
4340
-
4341
- if (mbfl_convert_encoding (& orig_str , & tmpstr , tran_cs ) != NULL ) {
4342
- tmpstr .encoding = & mbfl_encoding_8bit ;
4343
- pstr = mbfl_convert_encoding (& tmpstr , & conv_str , body_enc );
4344
- efree (tmpstr .val );
4345
- }
4346
- }
4347
- if (pstr != NULL ) {
4348
- message_buf = message = (char * )pstr -> val ;
4349
- }
4335
+ unsigned int num_errors = 0 ;
4336
+ zend_string * tmpstr = mb_fast_convert ((unsigned char * )message , message_len , msg_enc , tran_cs , '?' , MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR , & num_errors );
4337
+ zend_string * conv = mb_fast_convert ((unsigned char * )ZSTR_VAL (tmpstr ), ZSTR_LEN (tmpstr ), & mbfl_encoding_8bit , body_enc , '?' , MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR , & num_errors );
4338
+ zend_string_free (tmpstr );
4339
+ message = ZSTR_VAL (conv );
4350
4340
4351
4341
/* other headers */
4352
4342
#define PHP_MBSTR_MAIL_MIME_HEADER1 "MIME-Version: 1.0"
@@ -4401,11 +4391,7 @@ PHP_FUNCTION(mb_send_mail)
4401
4391
extra_cmd = php_escape_shell_cmd (ZSTR_VAL (extra_cmd ));
4402
4392
}
4403
4393
4404
- if (!err && php_mail (to_r , subject , message , ZSTR_VAL (str_headers ), extra_cmd ? ZSTR_VAL (extra_cmd ) : NULL )) {
4405
- RETVAL_TRUE ;
4406
- } else {
4407
- RETVAL_FALSE ;
4408
- }
4394
+ RETVAL_BOOL (!err && php_mail (to_r , subject , message , ZSTR_VAL (str_headers ), extra_cmd ? ZSTR_VAL (extra_cmd ) : NULL ));
4409
4395
4410
4396
if (extra_cmd ) {
4411
4397
zend_string_release_ex (extra_cmd , 0 );
@@ -4417,9 +4403,7 @@ PHP_FUNCTION(mb_send_mail)
4417
4403
if (subject_buf ) {
4418
4404
efree ((void * )subject_buf );
4419
4405
}
4420
- if (message_buf ) {
4421
- efree ((void * )message_buf );
4422
- }
4406
+ zend_string_free (conv );
4423
4407
mbfl_memory_device_clear (& device );
4424
4408
zend_hash_destroy (& ht_headers );
4425
4409
if (str_headers ) {
0 commit comments