@@ -195,13 +195,17 @@ ZEND_INI_BEGIN()
195
195
STD_ZEND_INI_ENTRY ("unicode.fallback_encoding" , NULL , ZEND_INI_ALL , OnUpdateEncoding , fallback_encoding_conv , zend_unicode_globals , unicode_globals )
196
196
STD_ZEND_INI_ENTRY ("unicode.runtime_encoding" , NULL , ZEND_INI_ALL , OnUpdateEncoding , runtime_encoding_conv , zend_unicode_globals , unicode_globals )
197
197
STD_ZEND_INI_ENTRY ("unicode.script_encoding" , NULL , ZEND_INI_ALL , OnUpdateEncoding , script_encoding_conv , zend_unicode_globals , unicode_globals )
198
- STD_ZEND_INI_ENTRY ("unicode.http_input_encoding" , NULL , ZEND_INI_ALL , OnUpdateEncoding , http_input_encoding_conv , zend_unicode_globals , unicode_globals )
199
198
STD_ZEND_INI_ENTRY ("unicode.filesystem_encoding" , NULL , ZEND_INI_ALL , OnUpdateEncoding , filesystem_encoding_conv , zend_unicode_globals , unicode_globals )
200
199
/*
201
200
* This is used as a default for the stream contexts. It's not an actual
202
201
* UConverter because each stream needs its own.
203
202
*/
204
203
STD_ZEND_INI_ENTRY ("unicode.stream_encoding" , "UTF-8" , ZEND_INI_ALL , OnUpdateStringUnempty , stream_encoding , zend_unicode_globals , unicode_globals )
204
+ /*
205
+ * This is used as a default for the request encoding. It's not an actual
206
+ * UConverter because the request encoding converter is reset on each request.
207
+ */
208
+ STD_ZEND_INI_ENTRY ("unicode.request_encoding_default" , "UTF-8" , ZEND_INI_ALL , OnUpdateStringUnempty , request_encoding_def , zend_unicode_globals , unicode_globals )
205
209
ZEND_INI_END ()
206
210
207
211
@@ -1008,8 +1012,8 @@ static void unicode_globals_ctor(zend_unicode_globals *unicode_globals TSRMLS_DC
1008
1012
unicode_globals -> runtime_encoding_conv = NULL ;
1009
1013
unicode_globals -> output_encoding_conv = NULL ;
1010
1014
unicode_globals -> script_encoding_conv = NULL ;
1011
- unicode_globals -> http_input_encoding_conv = NULL ;
1012
1015
unicode_globals -> filesystem_encoding_conv = NULL ;
1016
+ unicode_globals -> request_encoding_conv = NULL ;
1013
1017
zend_set_converter_encoding (& unicode_globals -> utf8_conv , "UTF-8" );
1014
1018
zend_set_converter_error_mode (unicode_globals -> utf8_conv , ZEND_TO_UNICODE , ZEND_CONV_ERROR_STOP );
1015
1019
zend_set_converter_encoding (& unicode_globals -> ascii_conv , "US-ASCII" );
@@ -1061,11 +1065,6 @@ static void unicode_globals_dtor(zend_unicode_globals *unicode_globals TSRMLS_DC
1061
1065
unicode_globals -> script_encoding_conv != unicode_globals -> ascii_conv ) {
1062
1066
ucnv_close (unicode_globals -> script_encoding_conv );
1063
1067
}
1064
- if (unicode_globals -> http_input_encoding_conv &&
1065
- unicode_globals -> http_input_encoding_conv != unicode_globals -> utf8_conv &&
1066
- unicode_globals -> http_input_encoding_conv != unicode_globals -> ascii_conv ) {
1067
- ucnv_close (unicode_globals -> http_input_encoding_conv );
1068
- }
1069
1068
if (unicode_globals -> utf8_conv ) {
1070
1069
ucnv_close (unicode_globals -> utf8_conv );
1071
1070
}
@@ -1385,12 +1384,24 @@ static void init_unicode_request_globals(TSRMLS_D) /* {{{ */
1385
1384
UG (default_locale ) = safe_estrdup (uloc_getDefault ());
1386
1385
UG (default_collator ) = NULL ;
1387
1386
1387
+ if (strcmp (UG (request_encoding_def ), "binary" ) != 0 ) {
1388
+ if (zend_set_converter_encoding (& UG (request_encoding_conv ), UG (request_encoding_def )) == FAILURE ) {
1389
+ zend_error (E_CORE_ERROR , "Unrecognized encoding '%s' used for request_encoding" , UG (request_encoding_def ));
1390
+ return ;
1391
+ }
1392
+ zend_set_converter_error_mode (UG (request_encoding_conv ), ZEND_TO_UNICODE , ZEND_CONV_ERROR_STOP );
1393
+ }
1394
+
1388
1395
zend_reset_locale_deps (TSRMLS_C );
1389
1396
}
1390
1397
/* }}} */
1391
1398
1392
1399
static void shutdown_unicode_request_globals (TSRMLS_D ) /* {{{ */
1393
1400
{
1401
+ if (UG (request_encoding_conv )) {
1402
+ ucnv_close (UG (request_encoding_conv ));
1403
+ UG (request_encoding_conv ) = NULL ;
1404
+ }
1394
1405
zend_collator_destroy (UG (default_collator ));
1395
1406
efree (UG (default_locale ));
1396
1407
}
0 commit comments