@@ -836,116 +836,6 @@ static PHP_INI_MH(OnUpdate_mbstring_detect_order)
836
836
}
837
837
/* }}} */
838
838
839
- static int _php_mb_ini_mbstring_http_input_set (const char * new_value , size_t new_value_length ) {
840
- const mbfl_encoding * * list ;
841
- size_t size ;
842
- if (FAILURE == php_mb_parse_encoding_list (new_value , new_value_length , & list , & size , 1 , 0 ) || size == 0 ) {
843
- return FAILURE ;
844
- }
845
- if (MBSTRG (http_input_list )) {
846
- pefree (MBSTRG (http_input_list ), 1 );
847
- }
848
- MBSTRG (http_input_list ) = list ;
849
- MBSTRG (http_input_list_size ) = size ;
850
- return SUCCESS ;
851
- }
852
-
853
- /* {{{ static PHP_INI_MH(OnUpdate_mbstring_http_input) */
854
- static PHP_INI_MH (OnUpdate_mbstring_http_input )
855
- {
856
- if (new_value ) {
857
- php_error_docref ("ref.mbstring" , E_DEPRECATED , "Use of mbstring.http_input is deprecated" );
858
- }
859
-
860
- if (!new_value || !ZSTR_VAL (new_value )) {
861
- const char * encoding = php_get_input_encoding ();
862
- MBSTRG (http_input_set ) = 0 ;
863
- _php_mb_ini_mbstring_http_input_set (encoding , strlen (encoding ));
864
- return SUCCESS ;
865
- }
866
-
867
- MBSTRG (http_input_set ) = 1 ;
868
- return _php_mb_ini_mbstring_http_input_set (ZSTR_VAL (new_value ), ZSTR_LEN (new_value ));
869
- }
870
- /* }}} */
871
-
872
- static int _php_mb_ini_mbstring_http_output_set (const char * new_value ) {
873
- const mbfl_encoding * encoding = mbfl_name2encoding (new_value );
874
- if (!encoding ) {
875
- return FAILURE ;
876
- }
877
-
878
- MBSTRG (http_output_encoding ) = encoding ;
879
- MBSTRG (current_http_output_encoding ) = encoding ;
880
- return SUCCESS ;
881
- }
882
-
883
- /* {{{ static PHP_INI_MH(OnUpdate_mbstring_http_output) */
884
- static PHP_INI_MH (OnUpdate_mbstring_http_output )
885
- {
886
- if (new_value ) {
887
- php_error_docref ("ref.mbstring" , E_DEPRECATED , "Use of mbstring.http_output is deprecated" );
888
- }
889
-
890
- if (new_value == NULL || ZSTR_LEN (new_value ) == 0 ) {
891
- MBSTRG (http_output_set ) = 0 ;
892
- _php_mb_ini_mbstring_http_output_set (php_get_output_encoding ());
893
- return SUCCESS ;
894
- }
895
-
896
- MBSTRG (http_output_set ) = 1 ;
897
- return _php_mb_ini_mbstring_http_output_set (ZSTR_VAL (new_value ));
898
- }
899
- /* }}} */
900
-
901
- /* {{{ static _php_mb_ini_mbstring_internal_encoding_set */
902
- static int _php_mb_ini_mbstring_internal_encoding_set (const char * new_value , size_t new_value_length )
903
- {
904
- const mbfl_encoding * encoding ;
905
-
906
- if (!new_value || !new_value_length || !(encoding = mbfl_name2encoding (new_value ))) {
907
- /* falls back to UTF-8 if an unknown encoding name is given */
908
- encoding = mbfl_no2encoding (mbfl_no_encoding_utf8 );
909
- }
910
- MBSTRG (internal_encoding ) = encoding ;
911
- MBSTRG (current_internal_encoding ) = encoding ;
912
- #if 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
839
/* {{{ static PHP_INI_MH(OnUpdate_mbstring_substitute_character) */
950
840
static PHP_INI_MH (OnUpdate_mbstring_substitute_character )
951
841
{
@@ -1039,9 +929,6 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output_conv_mimetypes)
1039
929
PHP_INI_BEGIN ()
1040
930
PHP_INI_ENTRY ("mbstring.language" , "neutral" , PHP_INI_ALL , OnUpdate_mbstring_language )
1041
931
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
932
PHP_INI_ENTRY ("mbstring.substitute_character" , NULL , PHP_INI_ALL , OnUpdate_mbstring_substitute_character )
1046
933
1047
934
STD_PHP_INI_BOOLEAN ("mbstring.encoding_translation" , "0" ,
@@ -1064,24 +951,6 @@ PHP_INI_BEGIN()
1064
951
PHP_INI_END ()
1065
952
/* }}} */
1066
953
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
954
/* {{{ module global initialize handler */
1086
955
static PHP_GINIT_FUNCTION (mbstring )
1087
956
{
@@ -1090,7 +959,7 @@ ZEND_TSRMLS_CACHE_UPDATE();
1090
959
#endif
1091
960
1092
961
mbstring_globals -> language = mbfl_no_language_uni ;
1093
- mbstring_globals -> internal_encoding = NULL ;
962
+ mbstring_globals -> internal_encoding = & mbfl_encoding_utf8 ;
1094
963
mbstring_globals -> current_internal_encoding = mbstring_globals -> internal_encoding ;
1095
964
mbstring_globals -> http_output_encoding = & mbfl_encoding_pass ;
1096
965
mbstring_globals -> current_http_output_encoding = & mbfl_encoding_pass ;
@@ -1145,6 +1014,58 @@ static PHP_GSHUTDOWN_FUNCTION(mbstring)
1145
1014
}
1146
1015
/* }}} */
1147
1016
1017
+ static void mbstring_internal_encoding_changed_hook (void ) {
1018
+ /* One of the internal_encoding / input_encoding / output_encoding ini settings changed. */
1019
+ const char * php_encoding = php_get_internal_encoding ();
1020
+ const mbfl_encoding * encoding ;
1021
+
1022
+ if (!MBSTRG (internal_encoding_set )) {
1023
+ if (!(encoding = mbfl_name2encoding (php_encoding ))) {
1024
+ /* falls back to UTF-8 if an unknown encoding name is given */
1025
+ encoding = mbfl_no2encoding (mbfl_no_encoding_utf8 );
1026
+ }
1027
+ MBSTRG (internal_encoding ) = encoding ;
1028
+ MBSTRG (current_internal_encoding ) = encoding ;
1029
+ #if HAVE_MBREGEX
1030
+ {
1031
+ const char * enc_name = php_encoding ;
1032
+ if (FAILURE == php_mb_regex_set_default_mbctype (enc_name )) {
1033
+ /* falls back to UTF-8 if an unknown encoding name is given */
1034
+ enc_name = "UTF-8" ;
1035
+ php_mb_regex_set_default_mbctype (enc_name );
1036
+ }
1037
+ php_mb_regex_set_mbctype (enc_name );
1038
+ }
1039
+ #endif
1040
+ }
1041
+
1042
+ if (!MBSTRG (http_output_set )) {
1043
+ php_encoding = php_get_output_encoding ();
1044
+ encoding = mbfl_name2encoding (php_encoding );
1045
+ if (!encoding ) {
1046
+ /* falls back to UTF-8 if an unknown encoding name is given */
1047
+ encoding = & mbfl_encoding_utf8 ;
1048
+ }
1049
+ MBSTRG (http_output_encoding ) = encoding ;
1050
+ MBSTRG (current_http_output_encoding ) = encoding ;
1051
+ }
1052
+
1053
+ if (!MBSTRG (http_input_set )) {
1054
+ php_encoding = php_get_input_encoding ();
1055
+ const mbfl_encoding * * list ;
1056
+ size_t size ;
1057
+ if (FAILURE == php_mb_parse_encoding_list (php_encoding , strlen (php_encoding ), & list , & size , 1 , 0 ) || size == 0 ) {
1058
+ /* on failure leave as is */
1059
+ return ;
1060
+ }
1061
+ if (MBSTRG (http_input_list )) {
1062
+ pefree (MBSTRG (http_input_list ), 1 );
1063
+ }
1064
+ MBSTRG (http_input_list ) = list ;
1065
+ MBSTRG (http_input_list_size ) = size ;
1066
+ }
1067
+ }
1068
+
1148
1069
/* {{{ PHP_MINIT_FUNCTION(mbstring) */
1149
1070
PHP_MINIT_FUNCTION (mbstring )
1150
1071
{
0 commit comments