- MFH: Fix a bug that mbstring.internal_encoding doesn't take effect within

the request encoding converter.
This commit is contained in:
Moriyoshi Koizumi 2009-03-15 20:42:56 +00:00
parent 49e408c55d
commit 716d2c9123
3 changed files with 13 additions and 8 deletions

View File

@ -59,6 +59,11 @@ MBSTRING_API SAPI_TREAT_DATA_FUNC(mbstr_treat_data)
enum mbfl_no_encoding detected;
php_mb_encoding_handler_info_t info;
{
char *value = zend_ini_string("mbstring.internal_encoding", sizeof("mbstring.internal_encoding"), 0);
_php_mb_ini_mbstring_internal_encoding_set(value, value ? strlen(value): 0 TSRMLS_CC);
}
if (!MBSTRG(encoding_translation)) {
php_default_treat_data(arg, str, destArray TSRMLS_CC);
return;

View File

@ -1203,7 +1203,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_output)
/* }}} */
/* {{{ static _php_mb_ini_mbstring_internal_encoding_set */
static int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length TSRMLS_DC)
int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length TSRMLS_DC)
{
enum mbfl_no_encoding no_encoding;
const char *enc_name = NULL;
@ -1370,7 +1370,6 @@ static PHP_INI_MH(OnUpdate_mbstring_encoding_translation)
if (MBSTRG(encoding_translation)) {
sapi_unregister_post_entry(php_post_entries TSRMLS_CC);
sapi_register_post_entries(mbstr_post_entries TSRMLS_CC);
sapi_register_treat_data(mbstr_treat_data);
} else {
sapi_unregister_post_entry(mbstr_post_entries TSRMLS_CC);
sapi_register_post_entries(php_post_entries TSRMLS_CC);
@ -1512,9 +1511,12 @@ PHP_MINIT_FUNCTION(mbstring)
REGISTER_INI_ENTRIES();
/* This is a global handler. Should not be set in a per-request handler. */
sapi_register_treat_data(mbstr_treat_data);
/* Post handlers are stored in the thread-local context. */
if (MBSTRG(encoding_translation)) {
sapi_register_post_entries(mbstr_post_entries TSRMLS_CC);
sapi_register_treat_data(mbstr_treat_data);
}
REGISTER_LONG_CONSTANT("MB_OVERLOAD_MAIL", MB_OVERLOAD_MAIL, CONST_CS | CONST_PERSISTENT);
@ -1553,11 +1555,6 @@ PHP_RINIT_FUNCTION(mbstring)
zend_function *func, *orig;
const struct mb_overload_def *p;
{
char *value = zend_ini_string("mbstring.internal_encoding", sizeof("mbstring.internal_encoding"), 0);
_php_mb_ini_mbstring_internal_encoding_set(value, value ? strlen(value): 0 TSRMLS_CC);
}
MBSTRG(current_internal_encoding) = MBSTRG(internal_encoding);
MBSTRG(current_http_output_encoding) = MBSTRG(http_output_encoding);
MBSTRG(current_filter_illegal_mode) = MBSTRG(filter_illegal_mode);

View File

@ -159,6 +159,9 @@ MBSTRING_API int php_mb_gpc_encoding_detector(char **arg_string, int *arg_length
MBSTRING_API int php_mb_stripos(int mode, const char *old_haystack, unsigned int old_haystack_len, const char *old_needle, unsigned int old_needle_len, long offset, const char *from_encoding TSRMLS_DC);
/* internal use only */
int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_value_length TSRMLS_DC);
ZEND_BEGIN_MODULE_GLOBALS(mbstring)
enum mbfl_no_language language;
enum mbfl_no_encoding internal_encoding;