@@ -299,8 +299,7 @@ static size_t count_commas(const char *p, const char *end) {
299
299
* Emits a ValueError in function context and a warning in INI context, in INI context arg_num must be 0.
300
300
*/
301
301
static zend_result php_mb_parse_encoding_list (const char * value , size_t value_length ,
302
- const mbfl_encoding * * * return_list , size_t * return_size , bool persistent , uint32_t arg_num ,
303
- bool allow_pass_encoding )
302
+ const mbfl_encoding * * * return_list , size_t * return_size , bool persistent , uint32_t arg_num )
304
303
{
305
304
if (value == NULL || value_length == 0 ) {
306
305
* return_list = NULL ;
@@ -351,8 +350,7 @@ static zend_result php_mb_parse_encoding_list(const char *value, size_t value_le
351
350
}
352
351
}
353
352
} else {
354
- const mbfl_encoding * encoding =
355
- allow_pass_encoding ? php_mb_get_encoding_or_pass_ex (p1 , p1_length ) : mbfl_name2encoding_ex (p1 , p1_length );
353
+ const mbfl_encoding * encoding = mbfl_name2encoding_ex (p1 , p1_length );
356
354
if (!encoding ) {
357
355
/* Called from an INI setting modification */
358
356
if (arg_num == 0 ) {
@@ -456,8 +454,12 @@ static const zend_encoding *php_mb_zend_encoding_detector(const unsigned char *a
456
454
list = (const zend_encoding * * )MBSTRG (current_detect_order_list );
457
455
list_size = MBSTRG (current_detect_order_list_size );
458
456
}
459
-
460
- return (const zend_encoding * )mb_guess_encoding ((unsigned char * )arg_string , arg_length , (const mbfl_encoding * * )list , list_size , false, false);
457
+ if (list_size == 1 && ((mbfl_encoding * )* list ) == & mbfl_encoding_pass ) {
458
+ /* Emulate behavior of previous implementation; it would never return "pass"
459
+ * from an encoding auto-detection operation */
460
+ return NULL ;
461
+ }
462
+ return (const zend_encoding * )mb_guess_encoding ((unsigned char * )arg_string , arg_length , (const mbfl_encoding * * )list , list_size , false, false);
461
463
}
462
464
463
465
static size_t php_mb_zend_encoding_converter (unsigned char * * to , size_t * to_length , const unsigned char * from , size_t from_length , const zend_encoding * encoding_to , const zend_encoding * encoding_from )
@@ -478,7 +480,7 @@ static zend_result php_mb_zend_encoding_list_parser(const char *encoding_list, s
478
480
return php_mb_parse_encoding_list (
479
481
encoding_list , encoding_list_len ,
480
482
(const mbfl_encoding * * * )return_list , return_size ,
481
- persistent , /* arg_num */ 0 , /* allow_pass_encoding */ 0 );
483
+ persistent , /* arg_num */ 0 );
482
484
}
483
485
484
486
static const zend_encoding * php_mb_zend_internal_encoding_getter (void )
@@ -716,7 +718,7 @@ static PHP_INI_MH(OnUpdate_mbstring_detect_order)
716
718
return SUCCESS ;
717
719
}
718
720
719
- if (FAILURE == php_mb_parse_encoding_list (ZSTR_VAL (new_value ), ZSTR_LEN (new_value ), & list , & size , /* persistent */ 1 , /* arg_num */ 0 , /* allow_pass_encoding */ 0 ) || size == 0 ) {
721
+ if (FAILURE == php_mb_parse_encoding_list (ZSTR_VAL (new_value ), ZSTR_LEN (new_value ), & list , & size , /* persistent */ 1 , /* arg_num */ 0 ) || size == 0 ) {
720
722
return FAILURE ;
721
723
}
722
724
@@ -732,7 +734,11 @@ static PHP_INI_MH(OnUpdate_mbstring_detect_order)
732
734
static zend_result _php_mb_ini_mbstring_http_input_set (const char * new_value , size_t new_value_length ) {
733
735
const mbfl_encoding * * list ;
734
736
size_t size ;
735
- if (FAILURE == php_mb_parse_encoding_list (new_value , new_value_length , & list , & size , /* persistent */ 1 , /* arg_num */ 0 , /* allow_pass_encoding */ 1 ) || size == 0 ) {
737
+ if (new_value_length == 4 && strncmp (new_value , "pass" , 4 ) == 0 ) {
738
+ list = (const mbfl_encoding * * )pecalloc (1 , sizeof (mbfl_encoding * ), 1 );
739
+ * list = & mbfl_encoding_pass ;
740
+ size = 1 ;
741
+ } else if (FAILURE == php_mb_parse_encoding_list (new_value , new_value_length , & list , & size , /* persistent */ 1 , /* arg_num */ 0 ) || size == 0 ) {
736
742
return FAILURE ;
737
743
}
738
744
if (MBSTRG (http_input_list )) {
@@ -1390,7 +1396,7 @@ PHP_FUNCTION(mb_detect_order)
1390
1396
RETURN_THROWS ();
1391
1397
}
1392
1398
} else {
1393
- if (FAILURE == php_mb_parse_encoding_list (ZSTR_VAL (order_str ), ZSTR_LEN (order_str ), & list , & size , /* persistent */ 0 , /* arg_num */ 1 , /* allow_pass_encoding */ 0 )) {
1399
+ if (FAILURE == php_mb_parse_encoding_list (ZSTR_VAL (order_str ), ZSTR_LEN (order_str ), & list , & size , /* persistent */ 0 , /* arg_num */ 1 )) {
1394
1400
RETURN_THROWS ();
1395
1401
}
1396
1402
}
@@ -2848,7 +2854,7 @@ PHP_FUNCTION(mb_convert_encoding)
2848
2854
} else if (from_encodings_str ) {
2849
2855
if (php_mb_parse_encoding_list (ZSTR_VAL (from_encodings_str ), ZSTR_LEN (from_encodings_str ),
2850
2856
& from_encodings , & num_from_encodings ,
2851
- /* persistent */ 0 , /* arg_num */ 3 , /* allow_pass_encoding */ 0 ) == FAILURE ) {
2857
+ /* persistent */ 0 , /* arg_num */ 3 ) == FAILURE ) {
2852
2858
RETURN_THROWS ();
2853
2859
}
2854
2860
free_from_encodings = true;
@@ -3377,7 +3383,7 @@ PHP_FUNCTION(mb_detect_encoding)
3377
3383
RETURN_THROWS ();
3378
3384
}
3379
3385
} else if (encoding_str ) {
3380
- if (FAILURE == php_mb_parse_encoding_list (ZSTR_VAL (encoding_str ), ZSTR_LEN (encoding_str ), & elist , & size , /* persistent */ 0 , /* arg_num */ 2 , /* allow_pass_encoding */ 0 )) {
3386
+ if (FAILURE == php_mb_parse_encoding_list (ZSTR_VAL (encoding_str ), ZSTR_LEN (encoding_str ), & elist , & size , /* persistent */ 0 , /* arg_num */ 2 )) {
3381
3387
RETURN_THROWS ();
3382
3388
}
3383
3389
} else {
@@ -3778,7 +3784,7 @@ PHP_FUNCTION(mb_convert_variables)
3778
3784
RETURN_THROWS ();
3779
3785
}
3780
3786
} else {
3781
- if (php_mb_parse_encoding_list (ZSTR_VAL (from_enc_str ), ZSTR_LEN (from_enc_str ), & elist , & elistsz , /* persistent */ 0 , /* arg_num */ 2 , /* allow_pass_encoding */ 0 ) == FAILURE ) {
3787
+ if (php_mb_parse_encoding_list (ZSTR_VAL (from_enc_str ), ZSTR_LEN (from_enc_str ), & elist , & elistsz , /* persistent */ 0 , /* arg_num */ 2 ) == FAILURE ) {
3782
3788
RETURN_THROWS ();
3783
3789
}
3784
3790
}
0 commit comments