@@ -832,120 +832,6 @@ static PHP_INI_MH(OnUpdate_mbstring_detect_order)
832
832
}
833
833
/* }}} */
834
834
835
- static int _php_mb_ini_mbstring_http_input_set (const char * new_value , size_t new_value_length ) {
836
- const mbfl_encoding * * list ;
837
- size_t size ;
838
- 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 ) {
839
- return FAILURE ;
840
- }
841
- if (MBSTRG (http_input_list )) {
842
- pefree (ZEND_VOIDP (MBSTRG (http_input_list )), 1 );
843
- }
844
- MBSTRG (http_input_list ) = list ;
845
- MBSTRG (http_input_list_size ) = size ;
846
- return SUCCESS ;
847
- }
848
-
849
- /* {{{ static PHP_INI_MH(OnUpdate_mbstring_http_input) */
850
- static PHP_INI_MH (OnUpdate_mbstring_http_input )
851
- {
852
- if (new_value ) {
853
- php_error_docref ("ref.mbstring" , E_DEPRECATED , "Use of mbstring.http_input is deprecated" );
854
- }
855
-
856
- if (!new_value || !ZSTR_VAL (new_value )) {
857
- const char * encoding = php_get_input_encoding ();
858
- MBSTRG (http_input_set ) = 0 ;
859
- _php_mb_ini_mbstring_http_input_set (encoding , strlen (encoding ));
860
- return SUCCESS ;
861
- }
862
-
863
- MBSTRG (http_input_set ) = 1 ;
864
- return _php_mb_ini_mbstring_http_input_set (ZSTR_VAL (new_value ), ZSTR_LEN (new_value ));
865
- }
866
- /* }}} */
867
-
868
- static int _php_mb_ini_mbstring_http_output_set (const char * new_value ) {
869
- const mbfl_encoding * encoding = php_mb_get_encoding_or_pass (new_value );
870
- if (!encoding ) {
871
- return FAILURE ;
872
- }
873
-
874
- MBSTRG (http_output_encoding ) = encoding ;
875
- MBSTRG (current_http_output_encoding ) = encoding ;
876
- return SUCCESS ;
877
- }
878
-
879
- /* {{{ static PHP_INI_MH(OnUpdate_mbstring_http_output) */
880
- static PHP_INI_MH (OnUpdate_mbstring_http_output )
881
- {
882
- if (new_value ) {
883
- php_error_docref ("ref.mbstring" , E_DEPRECATED , "Use of mbstring.http_output is deprecated" );
884
- }
885
-
886
- if (new_value == NULL || ZSTR_LEN (new_value ) == 0 ) {
887
- MBSTRG (http_output_set ) = 0 ;
888
- _php_mb_ini_mbstring_http_output_set (php_get_output_encoding ());
889
- return SUCCESS ;
890
- }
891
-
892
- MBSTRG (http_output_set ) = 1 ;
893
- return _php_mb_ini_mbstring_http_output_set (ZSTR_VAL (new_value ));
894
- }
895
- /* }}} */
896
-
897
- /* {{{ static _php_mb_ini_mbstring_internal_encoding_set */
898
- static int _php_mb_ini_mbstring_internal_encoding_set (const char * new_value , size_t new_value_length )
899
- {
900
- const mbfl_encoding * encoding ;
901
-
902
- if (!new_value || !new_value_length || !(encoding = mbfl_name2encoding (new_value ))) {
903
- /* falls back to UTF-8 if an unknown encoding name is given */
904
- if (new_value ) {
905
- php_error_docref ("ref.mbstring" , E_WARNING ,
906
- "Unknown encoding \"%s\" in ini setting" , new_value );
907
- }
908
- encoding = mbfl_no2encoding (mbfl_no_encoding_utf8 );
909
- }
910
- MBSTRG (internal_encoding ) = encoding ;
911
- MBSTRG (current_internal_encoding ) = encoding ;
912
- #ifdef HAVE_MBREGEX
913
- {
914
- const char * enc_name = new_value ;
915
- if (FAILURE == php_mb_regex_set_default_mbctype (enc_name )) {
916
- /* falls back to UTF-8 if an unknown encoding name is given */
917
- enc_name = "UTF-8" ;
918
- php_mb_regex_set_default_mbctype (enc_name );
919
- }
920
- php_mb_regex_set_mbctype (new_value );
921
- }
922
- #endif
923
- return SUCCESS ;
924
- }
925
- /* }}} */
926
-
927
- /* {{{ static PHP_INI_MH(OnUpdate_mbstring_internal_encoding) */
928
- static PHP_INI_MH (OnUpdate_mbstring_internal_encoding )
929
- {
930
- if (new_value ) {
931
- php_error_docref ("ref.mbstring" , E_DEPRECATED , "Use of mbstring.internal_encoding is deprecated" );
932
- }
933
-
934
- if (OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage ) == FAILURE ) {
935
- return FAILURE ;
936
- }
937
-
938
- if (new_value && ZSTR_LEN (new_value )) {
939
- MBSTRG (internal_encoding_set ) = 1 ;
940
- return _php_mb_ini_mbstring_internal_encoding_set (ZSTR_VAL (new_value ), ZSTR_LEN (new_value ));
941
- } else {
942
- const char * encoding = php_get_internal_encoding ();
943
- MBSTRG (internal_encoding_set ) = 0 ;
944
- return _php_mb_ini_mbstring_internal_encoding_set (encoding , strlen (encoding ));
945
- }
946
- }
947
- /* }}} */
948
-
949
835
/* {{{ static PHP_INI_MH(OnUpdate_mbstring_substitute_character) */
950
836
static PHP_INI_MH (OnUpdate_mbstring_substitute_character )
951
837
{
@@ -1039,9 +925,6 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output_conv_mimetypes)
1039
925
PHP_INI_BEGIN ()
1040
926
PHP_INI_ENTRY ("mbstring.language" , "neutral" , PHP_INI_ALL , OnUpdate_mbstring_language )
1041
927
PHP_INI_ENTRY ("mbstring.detect_order" , NULL , PHP_INI_ALL , OnUpdate_mbstring_detect_order )
1042
- PHP_INI_ENTRY ("mbstring.http_input" , NULL , PHP_INI_ALL , OnUpdate_mbstring_http_input )
1043
- PHP_INI_ENTRY ("mbstring.http_output" , NULL , PHP_INI_ALL , OnUpdate_mbstring_http_output )
1044
- STD_PHP_INI_ENTRY ("mbstring.internal_encoding" , NULL , PHP_INI_ALL , OnUpdate_mbstring_internal_encoding , internal_encoding_name , zend_mbstring_globals , mbstring_globals )
1045
928
PHP_INI_ENTRY ("mbstring.substitute_character" , NULL , PHP_INI_ALL , OnUpdate_mbstring_substitute_character )
1046
929
1047
930
STD_PHP_INI_BOOLEAN ("mbstring.encoding_translation" , "0" ,
@@ -1064,24 +947,6 @@ PHP_INI_BEGIN()
1064
947
PHP_INI_END ()
1065
948
/* }}} */
1066
949
1067
- static void mbstring_internal_encoding_changed_hook (void ) {
1068
- /* One of the internal_encoding / input_encoding / output_encoding ini settings changed. */
1069
- if (!MBSTRG (internal_encoding_set )) {
1070
- const char * encoding = php_get_internal_encoding ();
1071
- _php_mb_ini_mbstring_internal_encoding_set (encoding , strlen (encoding ));
1072
- }
1073
-
1074
- if (!MBSTRG (http_output_set )) {
1075
- const char * encoding = php_get_output_encoding ();
1076
- _php_mb_ini_mbstring_http_output_set (encoding );
1077
- }
1078
-
1079
- if (!MBSTRG (http_input_set )) {
1080
- const char * encoding = php_get_input_encoding ();
1081
- _php_mb_ini_mbstring_http_input_set (encoding , strlen (encoding ));
1082
- }
1083
- }
1084
-
1085
950
/* {{{ module global initialize handler */
1086
951
static PHP_GINIT_FUNCTION (mbstring )
1087
952
{
@@ -1090,7 +955,7 @@ ZEND_TSRMLS_CACHE_UPDATE();
1090
955
#endif
1091
956
1092
957
mbstring_globals -> language = mbfl_no_language_uni ;
1093
- mbstring_globals -> internal_encoding = NULL ;
958
+ mbstring_globals -> internal_encoding = & mbfl_encoding_utf8 ;
1094
959
mbstring_globals -> current_internal_encoding = mbstring_globals -> internal_encoding ;
1095
960
mbstring_globals -> http_output_encoding = & mbfl_encoding_pass ;
1096
961
mbstring_globals -> current_http_output_encoding = & mbfl_encoding_pass ;
@@ -1145,6 +1010,59 @@ static PHP_GSHUTDOWN_FUNCTION(mbstring)
1145
1010
}
1146
1011
/* }}} */
1147
1012
1013
+ static void mbstring_internal_encoding_changed_hook (void ) {
1014
+ /* One of the internal_encoding / input_encoding / output_encoding ini settings changed. */
1015
+ const char * php_encoding = php_get_internal_encoding ();
1016
+ const mbfl_encoding * encoding ;
1017
+
1018
+ if (!MBSTRG (internal_encoding_set )) {
1019
+ if (!(encoding = mbfl_name2encoding (php_encoding ))) {
1020
+ /* falls back to UTF-8 if an unknown encoding name is given */
1021
+ encoding = & mbfl_encoding_utf8 ;
1022
+ }
1023
+ MBSTRG (internal_encoding ) = encoding ;
1024
+ MBSTRG (current_internal_encoding ) = encoding ;
1025
+ #if HAVE_MBREGEX
1026
+ {
1027
+ const char * enc_name = php_encoding ;
1028
+ if (FAILURE == php_mb_regex_set_default_mbctype (enc_name )) {
1029
+ /* falls back to UTF-8 if an unknown encoding name is given */
1030
+ enc_name = "UTF-8" ;
1031
+ php_mb_regex_set_default_mbctype (enc_name );
1032
+ }
1033
+ php_mb_regex_set_mbctype (enc_name );
1034
+ }
1035
+ #endif
1036
+ }
1037
+
1038
+ if (!MBSTRG (http_output_set )) {
1039
+ php_encoding = php_get_output_encoding ();
1040
+ encoding = php_mb_get_encoding_or_pass (php_encoding );
1041
+ if (!encoding ) {
1042
+ /* falls back to UTF-8 if an unknown encoding name is given */
1043
+ encoding = & mbfl_encoding_utf8 ;
1044
+ }
1045
+ MBSTRG (http_output_encoding ) = encoding ;
1046
+ MBSTRG (current_http_output_encoding ) = encoding ;
1047
+ }
1048
+
1049
+ if (!MBSTRG (http_input_set )) {
1050
+ php_encoding = php_get_input_encoding ();
1051
+ const mbfl_encoding * * list ;
1052
+ size_t size ;
1053
+ if (FAILURE == php_mb_parse_encoding_list (php_encoding , strlen (php_encoding ), & list , & size ,
1054
+ /* persistent */ 1 , /* arg_num */ 0 , /* allow_pass_encoding */ 1 ) || size == 0 ) {
1055
+ /* on failure leave as is */
1056
+ return ;
1057
+ }
1058
+ if (MBSTRG (http_input_list )) {
1059
+ pefree (MBSTRG (http_input_list ), 1 );
1060
+ }
1061
+ MBSTRG (http_input_list ) = list ;
1062
+ MBSTRG (http_input_list_size ) = size ;
1063
+ }
1064
+ }
1065
+
1148
1066
/* {{{ PHP_MINIT_FUNCTION(mbstring) */
1149
1067
PHP_MINIT_FUNCTION (mbstring )
1150
1068
{
0 commit comments