@@ -1164,7 +1164,7 @@ PHP_FUNCTION(mb_parse_str)
1164
1164
len_list [n ] = 0 ;
1165
1165
}
1166
1166
n ++ ;
1167
- var = php_strtok_r (NULL , "&" , & strtok_buf );
1167
+ var = php_strtok_r (NULL , separator , & strtok_buf );
1168
1168
}
1169
1169
num = n ;
1170
1170
@@ -1267,6 +1267,8 @@ PHP_FUNCTION(mb_output_handler)
1267
1267
{
1268
1268
pval * * arg_string , * * arg_status ;
1269
1269
mbfl_string string , result , * ret ;
1270
+ const char * mimetype , * charset ;
1271
+ mbfl_memory_device device ;
1270
1272
SLS_FETCH ();
1271
1273
MBSTRLS_FETCH ();
1272
1274
@@ -1277,13 +1279,35 @@ PHP_FUNCTION(mb_output_handler)
1277
1279
convert_to_string_ex (arg_string );
1278
1280
convert_to_long_ex (arg_status );
1279
1281
1282
+ if ( SG (sapi_headers ).send_default_content_type && ! SG (headers_sent ) &&
1283
+ MBSTRG (current_http_output_encoding ) != mbfl_no_encoding_pass &&
1284
+ (Z_LVAL_PP (arg_status ) & PHP_OUTPUT_HANDLER_START ) != 0 ) {
1285
+ mimetype = SG (default_mimetype ) ? SG (default_mimetype ) : SAPI_DEFAULT_MIMETYPE ;
1286
+ charset = mbfl_no2preferred_mime_name (MBSTRG (current_http_output_encoding ));
1287
+ if ( charset != NULL && (* mimetype == '\0' || strncasecmp (mimetype , "text/" , 5 ) == 0 ) ) {
1288
+ mbfl_memory_device_init (& device , 0 , 0 );
1289
+ mbfl_memory_device_strcat (& device , "Content-Type: " );
1290
+ if (* mimetype == '\0' ) {
1291
+ mbfl_memory_device_strcat (& device , "text/html" );
1292
+ } else {
1293
+ mbfl_memory_device_strcat (& device , mimetype );
1294
+ }
1295
+ mbfl_memory_device_strcat (& device , ";charset=" );
1296
+ mbfl_memory_device_strcat (& device , charset );
1297
+ ret = mbfl_memory_device_result (& device , & result );
1298
+ if (ret != NULL ) {
1299
+ if (sapi_add_header (ret -> val , ret -> len , 0 ) != FAILURE ) {
1300
+ SG (sapi_headers ).send_default_content_type = 0 ;
1301
+ }
1302
+ }
1303
+ }
1304
+ }
1305
+
1280
1306
ret = NULL ;
1281
- if (SG (sapi_headers ).send_default_content_type &&
1282
- MBSTRG (current_http_output_encoding ) != mbfl_no_encoding_pass &&
1283
- MBSTRG (outconv ) == NULL ) {
1307
+ if (MBSTRG (current_http_output_encoding ) != mbfl_no_encoding_pass && MBSTRG (outconv ) == NULL ) {
1284
1308
MBSTRG (outconv ) = mbfl_buffer_converter_new (MBSTRG (current_internal_encoding ), MBSTRG (current_http_output_encoding ), 0 );
1285
1309
}
1286
- if (SG ( sapi_headers ). send_default_content_type && MBSTRG (outconv ) != NULL ) {
1310
+ if (MBSTRG ( current_http_output_encoding ) != mbfl_no_encoding_pass && MBSTRG (outconv ) != NULL ) {
1287
1311
mbfl_buffer_converter_illegal_mode (MBSTRG (outconv ), MBSTRG (current_filter_illegal_mode ));
1288
1312
mbfl_buffer_converter_illegal_substchar (MBSTRG (outconv ), MBSTRG (current_filter_illegal_substchar ));
1289
1313
mbfl_string_init (& string );
@@ -2256,7 +2280,7 @@ PHP_FUNCTION(mb_convert_variables)
2256
2280
if (Z_TYPE_PP (hash_entry ) == IS_ARRAY || Z_TYPE_PP (hash_entry ) == IS_OBJECT ) {
2257
2281
if (stack_level >= stack_max ) {
2258
2282
stack_max += PHP_MBSTR_STACK_BLOCK_SIZE ;
2259
- ptmp = erealloc (stack , stack_max );
2283
+ ptmp = erealloc (stack , sizeof ( pval * * ) * stack_max );
2260
2284
if (ptmp == NULL ) {
2261
2285
php_error (E_WARNING , "stack err at %s:(%d)" , __FILE__ , __LINE__ );
2262
2286
continue ;
@@ -2347,7 +2371,7 @@ PHP_FUNCTION(mb_convert_variables)
2347
2371
if (Z_TYPE_PP (hash_entry ) == IS_ARRAY || Z_TYPE_PP (hash_entry ) == IS_OBJECT ) {
2348
2372
if (stack_level >= stack_max ) {
2349
2373
stack_max += PHP_MBSTR_STACK_BLOCK_SIZE ;
2350
- ptmp = erealloc (stack , stack_max );
2374
+ ptmp = erealloc (stack , sizeof ( pval * * ) * stack_max );
2351
2375
if (ptmp == NULL ) {
2352
2376
php_error (E_WARNING , "stack err at %s:(%d)" , __FILE__ , __LINE__ );
2353
2377
continue ;
@@ -2497,13 +2521,13 @@ PHP_FUNCTION(mb_decode_numericentity)
2497
2521
2498
2522
2499
2523
#if HAVE_SENDMAIL
2500
- /* {{{ proto int mb_send_mail(string to, string subject, string message [, string additional_headers])
2524
+ /* {{{ proto int mb_send_mail(string to, string subject, string message [, string additional_headers [, string additional_parameters] ])
2501
2525
Sends an email message with MIME scheme */
2502
2526
PHP_FUNCTION (mb_send_mail )
2503
2527
{
2504
2528
int argc , n ;
2505
2529
pval * * argv [4 ];
2506
- char * to = NULL , * message = NULL , * headers = NULL , * subject = NULL ;
2530
+ char * to = NULL , * message = NULL , * headers = NULL , * subject = NULL , * extra_cmd = NULL ;
2507
2531
char * message_buf = NULL , * subject_buf = NULL , * p ;
2508
2532
mbfl_string orig_str , conv_str ;
2509
2533
mbfl_string * pstr ; /* pointer to mbfl string for return value */
@@ -2537,7 +2561,7 @@ PHP_FUNCTION(mb_send_mail)
2537
2561
}
2538
2562
2539
2563
argc = ZEND_NUM_ARGS ();
2540
- if (argc < 3 || argc > 4 || zend_get_parameters_array_ex (argc , argv ) == FAILURE ) {
2564
+ if (argc < 3 || argc > 5 || zend_get_parameters_array_ex (argc , argv ) == FAILURE ) {
2541
2565
WRONG_PARAM_COUNT ;
2542
2566
}
2543
2567
@@ -2621,7 +2645,12 @@ PHP_FUNCTION(mb_send_mail)
2621
2645
mbfl_memory_device_output ('\0' , & device );
2622
2646
headers = device .buffer ;
2623
2647
2624
- if (!err && php_mail (to , subject , message , headers , NULL )){
2648
+ if (argc == 5 ) { /* extra options that get passed to the mailer */
2649
+ convert_to_string_ex (argv [4 ]);
2650
+ extra_cmd = (* argv [4 ])-> value .str .val ;
2651
+ }
2652
+
2653
+ if (!err && php_mail (to , subject , message , headers , extra_cmd )){
2625
2654
RETVAL_TRUE ;
2626
2655
} else {
2627
2656
RETVAL_FALSE ;
0 commit comments