@@ -4168,7 +4168,7 @@ PHP_FUNCTION(mb_send_mail)
41684168 int cnt_trans_enc :1 ;
41694169 } suppressed_hdrs = { 0 , 0 };
41704170
4171- char * message_buf = NULL , * subject_buf = NULL , * p ;
4171+ char * subject_buf = NULL , * p ;
41724172 mbfl_string orig_str , conv_str ;
41734173 mbfl_string * pstr ; /* pointer to mbfl string for return value */
41744174 enum mbfl_no_encoding ;
@@ -4326,27 +4326,17 @@ PHP_FUNCTION(mb_send_mail)
43264326 }
43274327
43284328 /* 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 );
43324330
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 ));
43354333 }
43364334
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 );
43504340
43514341 /* other headers */
43524342#define PHP_MBSTR_MAIL_MIME_HEADER1 "MIME-Version: 1.0"
@@ -4401,11 +4391,7 @@ PHP_FUNCTION(mb_send_mail)
44014391 extra_cmd = php_escape_shell_cmd (ZSTR_VAL (extra_cmd ));
44024392 }
44034393
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 ));
44094395
44104396 if (extra_cmd ) {
44114397 zend_string_release_ex (extra_cmd , 0 );
@@ -4417,9 +4403,7 @@ PHP_FUNCTION(mb_send_mail)
44174403 if (subject_buf ) {
44184404 efree ((void * )subject_buf );
44194405 }
4420- if (message_buf ) {
4421- efree ((void * )message_buf );
4422- }
4406+ zend_string_free (conv );
44234407 mbfl_memory_device_clear (& device );
44244408 zend_hash_destroy (& ht_headers );
44254409 if (str_headers ) {
0 commit comments