Patch bug72992.patch for mbstring related Bug #72992
Patch version 2016-09-08 04:12 UTC
Return to Bug #72992 |
Download this patch
Patch Revisions:
Developer: yohgaki@php.net
diff --git a/ext/iconv/tests/iconv_default_charset.phpt b/ext/iconv/tests/iconv_default_charset.phpt
index ebfc7e6..cec5c02 100644
--- a/ext/iconv/tests/iconv_default_charset.phpt
+++ b/ext/iconv/tests/iconv_default_charset.phpt
@@ -68,10 +68,10 @@ string(5) "UTF-8"
--- results of alterations ---
string(10) "ISO-8859-1"
-string(0) ""
-string(0) ""
-string(0) ""
-string(0) ""
-string(0) ""
-string(0) ""
+string(10) "ISO-8859-1"
+string(10) "ISO-8859-1"
+string(10) "ISO-8859-1"
+string(10) "ISO-8859-1"
+string(10) "ISO-8859-1"
+string(10) "ISO-8859-1"
Done
diff --git a/ext/iconv/tests/iconv_ini_encoding.phpt b/ext/iconv/tests/iconv_ini_encoding.phpt
index 2d02b1c..a4eb989 100644
--- a/ext/iconv/tests/iconv_ini_encoding.phpt
+++ b/ext/iconv/tests/iconv_ini_encoding.phpt
@@ -53,12 +53,12 @@ string(0) ""
string(0) ""
Setting INI
string(10) "ISO-8859-1"
-string(0) ""
-string(0) ""
-string(0) ""
-string(10) "ISO-8859-1"
-string(0) ""
-string(0) ""
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
Getting INI
string(5) "UTF-8"
string(5) "UTF-8"
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 18e348d..024da7d 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -1260,7 +1260,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_input)
const mbfl_encoding **list;
size_t size;
- if (!new_value) {
+ if (!new_value || !new_value_length) {
if (MBSTRG(http_input_list)) {
pefree(MBSTRG(http_input_list), 1);
}
@@ -1328,7 +1328,7 @@ int _php_mb_ini_mbstring_internal_encoding_set(const char *new_value, uint new_v
{
const mbfl_encoding *encoding;
- if (!new_value || new_value_length == 0 || !(encoding = mbfl_name2encoding(new_value))) {
+ if (!new_value || !new_value_length || !(encoding = mbfl_name2encoding(new_value))) {
/* falls back to UTF-8 if an unknown encoding name is given */
encoding = mbfl_no2encoding(mbfl_no_encoding_utf8);
}
@@ -1361,7 +1361,7 @@ static PHP_INI_MH(OnUpdate_mbstring_internal_encoding)
}
if (stage & (PHP_INI_STAGE_STARTUP | PHP_INI_STAGE_SHUTDOWN | PHP_INI_STAGE_RUNTIME)) {
- if (new_value_length) {
+ if (new_value && new_value_length) {
return _php_mb_ini_mbstring_internal_encoding_set(new_value, new_value_length TSRMLS_CC);
} else {
return _php_mb_ini_mbstring_internal_encoding_set(get_internal_encoding(TSRMLS_C), strlen(get_internal_encoding(TSRMLS_C))+1 TSRMLS_CC);
diff --git a/ext/mbstring/tests/ini_encoding.phpt b/ext/mbstring/tests/ini_encoding.phpt
index b9809b2..2fb526a 100644
--- a/ext/mbstring/tests/ini_encoding.phpt
+++ b/ext/mbstring/tests/ini_encoding.phpt
@@ -57,12 +57,12 @@ string(9) "Shift_JIS"
string(9) "Shift_JIS"
Setting INI
string(9) "Shift_JIS"
-string(0) ""
-string(0) ""
-string(0) ""
-string(9) "Shift_JIS"
-string(9) "Shift_JIS"
-string(9) "Shift_JIS"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
+string(5) "UTF-8"
Getting INI
string(5) "UTF-8"
string(5) "UTF-8"
diff --git a/main/main.c b/main/main.c
index ab55b5b..3c19faf 100644
--- a/main/main.c
+++ b/main/main.c
@@ -419,8 +419,18 @@ static PHP_INI_DISP(display_errors_mode)
*/
static PHP_INI_MH(OnUpdateInternalEncoding)
{
- if (new_value) {
- OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ int old_error_reporting = EG(error_reporting);
+
+ OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ if ((stage & PHP_INI_STAGE_RUNTIME) && new_value && new_value_length) {
+ EG(error_reporting) = 0;
+ if (zend_hash_exists(&module_registry, "mbstring", sizeof("mbstring"))) {
+ zend_alter_ini_entry_ex("mbstring.internal_encoding", sizeof("mbstring.internal_encoding"), new_value, new_value_length, PHP_INI_ALL, stage, 0 TSRMLS_CC);
+ }
+ if (zend_hash_exists(&module_registry, "iconv", sizeof("iconv"))) {
+ zend_alter_ini_entry_ex("iconv.internal_encoding", sizeof("iconv.internal_encoding"), new_value, new_value_length, PHP_INI_ALL, stage, 0 TSRMLS_CC);
+ }
+ EG(error_reporting) = old_error_reporting;
}
return SUCCESS;
}
@@ -430,8 +440,18 @@ static PHP_INI_MH(OnUpdateInternalEncoding)
*/
static PHP_INI_MH(OnUpdateInputEncoding)
{
- if (new_value) {
- OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ int old_error_reporting = EG(error_reporting);
+
+ OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ if ((stage & PHP_INI_STAGE_RUNTIME) && new_value && new_value_length) {
+ EG(error_reporting) = 0;
+ if (zend_hash_exists(&module_registry, "mbstring", sizeof("mbstring"))) {
+ zend_alter_ini_entry_ex("mbstring.http_input", sizeof("mbstring.http_input"), new_value, new_value_length, PHP_INI_ALL, stage, 0 TSRMLS_CC);
+ }
+ if (zend_hash_exists(&module_registry, "iconv", sizeof("iconv"))) {
+ zend_alter_ini_entry_ex("iconv.input_encoding", sizeof("iconv.input_encoding"), new_value, new_value_length, PHP_INI_ALL, stage, 0 TSRMLS_CC);
+ }
+ EG(error_reporting) = old_error_reporting;
}
return SUCCESS;
}
@@ -441,8 +461,18 @@ static PHP_INI_MH(OnUpdateInputEncoding)
*/
static PHP_INI_MH(OnUpdateOutputEncoding)
{
- if (new_value) {
- OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ int old_error_reporting = EG(error_reporting);
+
+ OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ if ((stage & PHP_INI_STAGE_RUNTIME) && new_value && new_value_length) {
+ EG(error_reporting) = 0;
+ if (zend_hash_exists(&module_registry, "mbstring", sizeof("mbstring"))) {
+ zend_alter_ini_entry_ex("mbstring.http_output", sizeof("mbstring.http_output"), new_value, new_value_length, PHP_INI_ALL, stage, 0 TSRMLS_CC);
+ }
+ if (zend_hash_exists(&module_registry, "iconv", sizeof("iconv"))) {
+ zend_alter_ini_entry_ex("iconv.output_encoding", sizeof("iconv.output_encoding"), new_value, new_value_length, PHP_INI_ALL, stage, 0 TSRMLS_CC);
+ }
+ EG(error_reporting) = old_error_reporting;
}
return SUCCESS;
}
@@ -528,6 +558,24 @@ static PHP_INI_MH(OnChangeAlwaysPopulateRawPostData)
}
/* }}} */
+
+/* {{{ PHP_INI_MH
+ */
+static PHP_INI_MH(OnUpdateDefaultCharset)
+{
+ TSRMLS_FETCH();
+
+ OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
+ if ((stage & PHP_INI_STAGE_RUNTIME) && new_value && new_value_length) {
+ zend_alter_ini_entry_ex("internal_encoding", sizeof("internal_encoding"), new_value, new_value_length, PHP_INI_ALL, stage, 0 TSRMLS_CC);
+ zend_alter_ini_entry_ex("input_encoding", sizeof("input_encoding"), new_value, new_value_length, PHP_INI_ALL, stage, 0 TSRMLS_CC);
+ zend_alter_ini_entry_ex("output_encoding", sizeof("output_encoding"), new_value, new_value_length, PHP_INI_ALL, stage, 0 TSRMLS_CC);
+ }
+ return SUCCESS;
+}
+/* }}} */
+
+
/* Need to be read from the environment (?):
* PHP_AUTO_PREPEND_FILE
* PHP_AUTO_APPEND_FILE
@@ -589,7 +637,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, auto_append_file, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, auto_prepend_file, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals)
- STD_PHP_INI_ENTRY("default_charset", PHP_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateString, default_charset, sapi_globals_struct, sapi_globals)
+ STD_PHP_INI_ENTRY("default_charset", PHP_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateDefaultCharset, default_charset, sapi_globals_struct, sapi_globals)
STD_PHP_INI_ENTRY("default_mimetype", SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateString, default_mimetype, sapi_globals_struct, sapi_globals)
STD_PHP_INI_ENTRY("internal_encoding", NULL, PHP_INI_ALL, OnUpdateInternalEncoding, internal_encoding, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("input_encoding", NULL, PHP_INI_ALL, OnUpdateInputEncoding, input_encoding, php_core_globals, core_globals)
|