@@ -888,116 +888,6 @@ static PHP_INI_MH(OnUpdate_mbstring_detect_order)
888
888
}
889
889
/* }}} */
890
890
891
- static int _php_mb_ini_mbstring_http_input_set (const char * new_value , size_t new_value_length ) {
892
- const mbfl_encoding * * list ;
893
- size_t size ;
894
- if (FAILURE == php_mb_parse_encoding_list (new_value , new_value_length , & list , & size , 1 , 0 ) || size == 0 ) {
895
- return FAILURE ;
896
- }
897
- if (MBSTRG (http_input_list )) {
898
- pefree (MBSTRG (http_input_list ), 1 );
899
- }
900
- MBSTRG (http_input_list ) = list ;
901
- MBSTRG (http_input_list_size ) = size ;
902
- return SUCCESS ;
903
- }
904
-
905
- /* {{{ static PHP_INI_MH(OnUpdate_mbstring_http_input) */
906
- static PHP_INI_MH (OnUpdate_mbstring_http_input )
907
- {
908
- if (new_value ) {
909
- php_error_docref ("ref.mbstring" , E_DEPRECATED , "Use of mbstring.http_input is deprecated" );
910
- }
911
-
912
- if (!new_value || !ZSTR_VAL (new_value )) {
913
- const char * encoding = php_get_input_encoding ();
914
- MBSTRG (http_input_set ) = 0 ;
915
- _php_mb_ini_mbstring_http_input_set (encoding , strlen (encoding ));
916
- return SUCCESS ;
917
- }
918
-
919
- MBSTRG (http_input_set ) = 1 ;
920
- return _php_mb_ini_mbstring_http_input_set (ZSTR_VAL (new_value ), ZSTR_LEN (new_value ));
921
- }
922
- /* }}} */
923
-
924
- static int _php_mb_ini_mbstring_http_output_set (const char * new_value ) {
925
- const mbfl_encoding * encoding = mbfl_name2encoding (new_value );
926
- if (!encoding ) {
927
- return FAILURE ;
928
- }
929
-
930
- MBSTRG (http_output_encoding ) = encoding ;
931
- MBSTRG (current_http_output_encoding ) = encoding ;
932
- return SUCCESS ;
933
- }
934
-
935
- /* {{{ static PHP_INI_MH(OnUpdate_mbstring_http_output) */
936
- static PHP_INI_MH (OnUpdate_mbstring_http_output )
937
- {
938
- if (new_value ) {
939
- php_error_docref ("ref.mbstring" , E_DEPRECATED , "Use of mbstring.http_output is deprecated" );
940
- }
941
-
942
- if (new_value == NULL || ZSTR_LEN (new_value ) == 0 ) {
943
- MBSTRG (http_output_set ) = 0 ;
944
- _php_mb_ini_mbstring_http_output_set (php_get_output_encoding ());
945
- return SUCCESS ;
946
- }
947
-
948
- MBSTRG (http_output_set ) = 1 ;
949
- return _php_mb_ini_mbstring_http_output_set (ZSTR_VAL (new_value ));
950
- }
951
- /* }}} */
952
-
953
- /* {{{ static _php_mb_ini_mbstring_internal_encoding_set */
954
- static int _php_mb_ini_mbstring_internal_encoding_set (const char * new_value , size_t new_value_length )
955
- {
956
- const mbfl_encoding * encoding ;
957
-
958
- if (!new_value || !new_value_length || !(encoding = mbfl_name2encoding (new_value ))) {
959
- /* falls back to UTF-8 if an unknown encoding name is given */
960
- encoding = mbfl_no2encoding (mbfl_no_encoding_utf8 );
961
- }
962
- MBSTRG (internal_encoding ) = encoding ;
963
- MBSTRG (current_internal_encoding ) = encoding ;
964
- #if HAVE_MBREGEX
965
- {
966
- const char * enc_name = new_value ;
967
- if (FAILURE == php_mb_regex_set_default_mbctype (enc_name )) {
968
- /* falls back to UTF-8 if an unknown encoding name is given */
969
- enc_name = "UTF-8" ;
970
- php_mb_regex_set_default_mbctype (enc_name );
971
- }
972
- php_mb_regex_set_mbctype (new_value );
973
- }
974
- #endif
975
- return SUCCESS ;
976
- }
977
- /* }}} */
978
-
979
- /* {{{ static PHP_INI_MH(OnUpdate_mbstring_internal_encoding) */
980
- static PHP_INI_MH (OnUpdate_mbstring_internal_encoding )
981
- {
982
- if (new_value ) {
983
- php_error_docref ("ref.mbstring" , E_DEPRECATED , "Use of mbstring.internal_encoding is deprecated" );
984
- }
985
-
986
- if (OnUpdateString (entry , new_value , mh_arg1 , mh_arg2 , mh_arg3 , stage ) == FAILURE ) {
987
- return FAILURE ;
988
- }
989
-
990
- if (new_value && ZSTR_LEN (new_value )) {
991
- MBSTRG (internal_encoding_set ) = 1 ;
992
- return _php_mb_ini_mbstring_internal_encoding_set (ZSTR_VAL (new_value ), ZSTR_LEN (new_value ));
993
- } else {
994
- const char * encoding = php_get_internal_encoding ();
995
- MBSTRG (internal_encoding_set ) = 0 ;
996
- return _php_mb_ini_mbstring_internal_encoding_set (encoding , strlen (encoding ));
997
- }
998
- }
999
- /* }}} */
1000
-
1001
891
/* {{{ static PHP_INI_MH(OnUpdate_mbstring_substitute_character) */
1002
892
static PHP_INI_MH (OnUpdate_mbstring_substitute_character )
1003
893
{
@@ -1091,9 +981,6 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output_conv_mimetypes)
1091
981
PHP_INI_BEGIN ()
1092
982
PHP_INI_ENTRY ("mbstring.language" , "neutral" , PHP_INI_ALL , OnUpdate_mbstring_language )
1093
983
PHP_INI_ENTRY ("mbstring.detect_order" , NULL , PHP_INI_ALL , OnUpdate_mbstring_detect_order )
1094
- PHP_INI_ENTRY ("mbstring.http_input" , NULL , PHP_INI_ALL , OnUpdate_mbstring_http_input )
1095
- PHP_INI_ENTRY ("mbstring.http_output" , NULL , PHP_INI_ALL , OnUpdate_mbstring_http_output )
1096
- STD_PHP_INI_ENTRY ("mbstring.internal_encoding" , NULL , PHP_INI_ALL , OnUpdate_mbstring_internal_encoding , internal_encoding_name , zend_mbstring_globals , mbstring_globals )
1097
984
PHP_INI_ENTRY ("mbstring.substitute_character" , NULL , PHP_INI_ALL , OnUpdate_mbstring_substitute_character )
1098
985
1099
986
STD_PHP_INI_BOOLEAN ("mbstring.encoding_translation" , "0" ,
@@ -1116,24 +1003,6 @@ PHP_INI_BEGIN()
1116
1003
PHP_INI_END ()
1117
1004
/* }}} */
1118
1005
1119
- static void mbstring_internal_encoding_changed_hook (void ) {
1120
- /* One of the internal_encoding / input_encoding / output_encoding ini settings changed. */
1121
- if (!MBSTRG (internal_encoding_set )) {
1122
- const char * encoding = php_get_internal_encoding ();
1123
- _php_mb_ini_mbstring_internal_encoding_set (encoding , strlen (encoding ));
1124
- }
1125
-
1126
- if (!MBSTRG (http_output_set )) {
1127
- const char * encoding = php_get_output_encoding ();
1128
- _php_mb_ini_mbstring_http_output_set (encoding );
1129
- }
1130
-
1131
- if (!MBSTRG (http_input_set )) {
1132
- const char * encoding = php_get_input_encoding ();
1133
- _php_mb_ini_mbstring_http_input_set (encoding , strlen (encoding ));
1134
- }
1135
- }
1136
-
1137
1006
/* {{{ module global initialize handler */
1138
1007
static PHP_GINIT_FUNCTION (mbstring )
1139
1008
{
@@ -1142,7 +1011,7 @@ ZEND_TSRMLS_CACHE_UPDATE();
1142
1011
#endif
1143
1012
1144
1013
mbstring_globals -> language = mbfl_no_language_uni ;
1145
- mbstring_globals -> internal_encoding = NULL ;
1014
+ mbstring_globals -> internal_encoding = & mbfl_encoding_utf8 ;
1146
1015
mbstring_globals -> current_internal_encoding = mbstring_globals -> internal_encoding ;
1147
1016
mbstring_globals -> http_output_encoding = & mbfl_encoding_pass ;
1148
1017
mbstring_globals -> current_http_output_encoding = & mbfl_encoding_pass ;
@@ -1197,6 +1066,58 @@ static PHP_GSHUTDOWN_FUNCTION(mbstring)
1197
1066
}
1198
1067
/* }}} */
1199
1068
1069
+ static void mbstring_internal_encoding_changed_hook (void ) {
1070
+ /* One of the internal_encoding / input_encoding / output_encoding ini settings changed. */
1071
+ const char * php_encoding = php_get_internal_encoding ();
1072
+ const mbfl_encoding * encoding ;
1073
+
1074
+ if (!MBSTRG (internal_encoding_set )) {
1075
+ if (!(encoding = mbfl_name2encoding (php_encoding ))) {
1076
+ /* falls back to UTF-8 if an unknown encoding name is given */
1077
+ encoding = mbfl_no2encoding (mbfl_no_encoding_utf8 );
1078
+ }
1079
+ MBSTRG (internal_encoding ) = encoding ;
1080
+ MBSTRG (current_internal_encoding ) = encoding ;
1081
+ #if HAVE_MBREGEX
1082
+ {
1083
+ const char * enc_name = php_encoding ;
1084
+ if (FAILURE == php_mb_regex_set_default_mbctype (enc_name )) {
1085
+ /* falls back to UTF-8 if an unknown encoding name is given */
1086
+ enc_name = "UTF-8" ;
1087
+ php_mb_regex_set_default_mbctype (enc_name );
1088
+ }
1089
+ php_mb_regex_set_mbctype (enc_name );
1090
+ }
1091
+ #endif
1092
+ }
1093
+
1094
+ if (!MBSTRG (http_output_set )) {
1095
+ php_encoding = php_get_output_encoding ();
1096
+ encoding = mbfl_name2encoding (php_encoding );
1097
+ if (!encoding ) {
1098
+ /* falls back to UTF-8 if an unknown encoding name is given */
1099
+ encoding = & mbfl_encoding_utf8 ;
1100
+ }
1101
+ MBSTRG (http_output_encoding ) = encoding ;
1102
+ MBSTRG (current_http_output_encoding ) = encoding ;
1103
+ }
1104
+
1105
+ if (!MBSTRG (http_input_set )) {
1106
+ php_encoding = php_get_input_encoding ();
1107
+ const mbfl_encoding * * list ;
1108
+ size_t size ;
1109
+ if (FAILURE == php_mb_parse_encoding_list (php_encoding , strlen (php_encoding ), & list , & size , 1 , 0 ) || size == 0 ) {
1110
+ /* on failure leave as is */
1111
+ return ;
1112
+ }
1113
+ if (MBSTRG (http_input_list )) {
1114
+ pefree (MBSTRG (http_input_list ), 1 );
1115
+ }
1116
+ MBSTRG (http_input_list ) = list ;
1117
+ MBSTRG (http_input_list_size ) = size ;
1118
+ }
1119
+ }
1120
+
1200
1121
/* {{{ PHP_MINIT_FUNCTION(mbstring) */
1201
1122
PHP_MINIT_FUNCTION (mbstring )
1202
1123
{
0 commit comments