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