@@ -4128,7 +4128,9 @@ PHP_FUNCTION(mb_send_mail)
4128
4128
|| orig_str .encoding -> no_encoding == mbfl_no_encoding_pass ) {
4129
4129
orig_str .encoding = mbfl_identify_encoding (& orig_str , MBSTRG (current_detect_order_list ), MBSTRG (current_detect_order_list_size ), MBSTRG (strict_detection ));
4130
4130
}
4131
- pstr = mbfl_mime_header_encode (& orig_str , & conv_str , tran_cs , head_enc , CRLF , sizeof ("Subject: [PHP-jp nnnnnnnn]" CRLF ) - 1 );
4131
+ const char * line_sep = PG (mail_mixed_lf_and_crlf ) ? "\n" : CRLF ;
4132
+ size_t line_sep_len = strlen (line_sep );
4133
+ pstr = mbfl_mime_header_encode (& orig_str , & conv_str , tran_cs , head_enc , line_sep , strlen ("Subject: [PHP-jp nnnnnnnn]" ) + line_sep_len );
4132
4134
if (pstr != NULL ) {
4133
4135
subject_buf = subject = (char * )pstr -> val ;
4134
4136
}
@@ -4167,14 +4169,14 @@ PHP_FUNCTION(mb_send_mail)
4167
4169
n = ZSTR_LEN (str_headers );
4168
4170
mbfl_memory_device_strncat (& device , p , n );
4169
4171
if (n > 0 && p [n - 1 ] != '\n' ) {
4170
- mbfl_memory_device_strncat (& device , CRLF , sizeof ( CRLF ) - 1 );
4172
+ mbfl_memory_device_strncat (& device , line_sep , line_sep_len );
4171
4173
}
4172
4174
zend_string_release_ex (str_headers , 0 );
4173
4175
}
4174
4176
4175
4177
if (!zend_hash_str_exists (& ht_headers , "mime-version" , sizeof ("mime-version" ) - 1 )) {
4176
4178
mbfl_memory_device_strncat (& device , PHP_MBSTR_MAIL_MIME_HEADER1 , sizeof (PHP_MBSTR_MAIL_MIME_HEADER1 ) - 1 );
4177
- mbfl_memory_device_strncat (& device , CRLF , sizeof ( CRLF ) - 1 );
4179
+ mbfl_memory_device_strncat (& device , line_sep , line_sep_len );
4178
4180
}
4179
4181
4180
4182
if (!suppressed_hdrs .cnt_type ) {
@@ -4185,7 +4187,7 @@ PHP_FUNCTION(mb_send_mail)
4185
4187
mbfl_memory_device_strncat (& device , PHP_MBSTR_MAIL_MIME_HEADER3 , sizeof (PHP_MBSTR_MAIL_MIME_HEADER3 ) - 1 );
4186
4188
mbfl_memory_device_strcat (& device , p );
4187
4189
}
4188
- mbfl_memory_device_strncat (& device , CRLF , sizeof ( CRLF ) - 1 );
4190
+ mbfl_memory_device_strncat (& device , line_sep , line_sep_len );
4189
4191
}
4190
4192
if (!suppressed_hdrs .cnt_trans_enc ) {
4191
4193
mbfl_memory_device_strncat (& device , PHP_MBSTR_MAIL_MIME_HEADER4 , sizeof (PHP_MBSTR_MAIL_MIME_HEADER4 ) - 1 );
@@ -4194,10 +4196,12 @@ PHP_FUNCTION(mb_send_mail)
4194
4196
p = "7bit" ;
4195
4197
}
4196
4198
mbfl_memory_device_strcat (& device , p );
4197
- mbfl_memory_device_strncat (& device , CRLF , sizeof ( CRLF ) - 1 );
4199
+ mbfl_memory_device_strncat (& device , line_sep , line_sep_len );
4198
4200
}
4199
4201
4200
- mbfl_memory_device_unput (& device );
4202
+ if (!PG (mail_mixed_lf_and_crlf )) {
4203
+ mbfl_memory_device_unput (& device );
4204
+ }
4201
4205
mbfl_memory_device_unput (& device );
4202
4206
mbfl_memory_device_output ('\0' , & device );
4203
4207
str_headers = zend_string_init ((char * )device .buffer , strlen ((char * )device .buffer ), 0 );
0 commit comments