diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index ea6ac1a1f16..87ad5eeaab0 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -220,21 +220,55 @@ static char _generic_superset_name[] = ICONV_UCS4_ENCODING; #define GENERIC_SUPERSET_NBYTES 4 /* }}} */ -static PHP_INI_MH(OnUpdateStringIconvCharset) + +static PHP_INI_MH(OnUpdateInputEncoding) +{ + if (new_value_length >= ICONV_CSNMAXLEN) { + return FAILURE; + } + if (new_value_length) { + OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } else { + OnUpdateString(entry, PG(input_encoding), strlen(PG(input_encoding))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } + return SUCCESS; +} + + +static PHP_INI_MH(OnUpdateOutputEncoding) { if(new_value_length >= ICONV_CSNMAXLEN) { return FAILURE; } - OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + if (new_value_length) { + OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } else { + OnUpdateString(entry, PG(output_encoding), strlen(PG(output_encoding))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } return SUCCESS; } + +static PHP_INI_MH(OnUpdateInternalEncoding) +{ + if(new_value_length >= ICONV_CSNMAXLEN) { + return FAILURE; + } + if (new_value_length) { + OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } else { + OnUpdateString(entry, PG(internal_encoding), strlen(PG(internal_encoding))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } + return SUCCESS; +} + + /* {{{ PHP_INI */ PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("iconv.input_encoding", ICONV_INPUT_ENCODING, PHP_INI_ALL, OnUpdateStringIconvCharset, input_encoding, zend_iconv_globals, iconv_globals) - STD_PHP_INI_ENTRY("iconv.output_encoding", ICONV_OUTPUT_ENCODING, PHP_INI_ALL, OnUpdateStringIconvCharset, output_encoding, zend_iconv_globals, iconv_globals) - STD_PHP_INI_ENTRY("iconv.internal_encoding", ICONV_INTERNAL_ENCODING, PHP_INI_ALL, OnUpdateStringIconvCharset, internal_encoding, zend_iconv_globals, iconv_globals) + STD_PHP_INI_ENTRY("iconv.input_encoding", "", PHP_INI_ALL, OnUpdateInputEncoding, input_encoding, zend_iconv_globals, iconv_globals) + STD_PHP_INI_ENTRY("iconv.output_encoding", "", PHP_INI_ALL, OnUpdateOutputEncoding, output_encoding, zend_iconv_globals, iconv_globals) + STD_PHP_INI_ENTRY("iconv.internal_encoding", "", PHP_INI_ALL, OnUpdateInternalEncoding, internal_encoding, zend_iconv_globals, iconv_globals) PHP_INI_END() /* }}} */ diff --git a/ext/iconv/php_iconv.h b/ext/iconv/php_iconv.h index 26e3f3b2a61..1389d7a9936 100644 --- a/ext/iconv/php_iconv.h +++ b/ext/iconv/php_iconv.h @@ -79,15 +79,9 @@ ZEND_END_MODULE_GLOBALS(iconv) #endif #ifdef HAVE_IBM_ICONV -# define ICONV_INPUT_ENCODING "ISO8859-1" -# define ICONV_OUTPUT_ENCODING "ISO8859-1" -# define ICONV_INTERNAL_ENCODING "ISO8859-1" # define ICONV_ASCII_ENCODING "IBM-850" # define ICONV_UCS4_ENCODING "UCS-4" #else -# define ICONV_INPUT_ENCODING "ISO-8859-1" -# define ICONV_OUTPUT_ENCODING "ISO-8859-1" -# define ICONV_INTERNAL_ENCODING "ISO-8859-1" # define ICONV_ASCII_ENCODING "ASCII" # define ICONV_UCS4_ENCODING "UCS-4LE" #endif diff --git a/ext/iconv/tests/iconv_ini_encoding.phpt b/ext/iconv/tests/iconv_ini_encoding.phpt new file mode 100644 index 00000000000..b9a69824e1d --- /dev/null +++ b/ext/iconv/tests/iconv_ini_encoding.phpt @@ -0,0 +1,68 @@ +--TEST-- +Encoding INI test +--SKIPIF-- + +--INI-- +default_charset=ISO-8859-1 +internal_encoding= +input_encoding= +output_encoding= +iconv.internal_encoding=ISO-8859-1 +iconv.http_input=ISO-8859-1 +iconv.http_output=ISO-8859-1 +--FILE-- +no_encoding; + /* these are not needed. convd has encoding info. + string.no_language = MBSTRG(language); + string.no_encoding = MBSTRG(current_internal_encoding)->no_encoding; + */ string.val = (unsigned char *)arg_string; string.len = arg_string_len; mbfl_buffer_converter_feed(MBSTRG(outconv), &string); diff --git a/ext/mbstring/tests/ini_encoding.phpt b/ext/mbstring/tests/ini_encoding.phpt new file mode 100644 index 00000000000..79a0f3aad47 --- /dev/null +++ b/ext/mbstring/tests/ini_encoding.phpt @@ -0,0 +1,73 @@ +--TEST-- +Encoding INI test +--SKIPIF-- + +--INI-- +default_charset=Shift_JIS +internal_encoding= +input_encoding= +output_encoding= +mbstring.internal_encoding=Shift_JIS +mbstring.http_input=Shift_JIS +mbstring.http_output=Shift_JIS +--FILE-- + ---------- X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 ---------- ---------- -Content-type: text/html +Content-type: text/html; charset=UTF-8 ---------- ---------- X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 ---------- ---------- -Content-type: text/html +Content-type: text/html; charset=UTF-8 ---------- ---------- X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 ---------- ---------- X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 Warning: Header to delete may not contain colon. in %s on line 2 @@ -158,7 +158,7 @@ header_remove("X-Foo"); ---------- X-Powered-By: PHP/%s X-Foo: Bar -Content-type: text/html +Content-type: text/html; charset=UTF-8 flush diff --git a/sapi/cli/tests/bug43177.phpt b/sapi/cli/tests/bug43177.phpt index 36b5504ab06..a97769cf8f1 100644 --- a/sapi/cli/tests/bug43177.phpt +++ b/sapi/cli/tests/bug43177.phpt @@ -60,23 +60,23 @@ HTTP/1.1 200 OK Host: localhost Connection: close X-Powered-By: %s -Content-type: text/html +Content-type: text/html; charset=UTF-8 OK HTTP/1.0 500 Internal Server Error Host: localhost Connection: close X-Powered-By: %s -Content-type: text/html +Content-type: text/html; charset=UTF-8 HTTP/1.0 500 Internal Server Error Host: localhost Connection: close X-Powered-By: %s -Content-type: text/html +Content-type: text/html; charset=UTF-8 HTTP/1.0 500 Internal Server Error Host: localhost Connection: close X-Powered-By: %s -Content-type: text/html +Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug65066_100.phpt b/sapi/cli/tests/bug65066_100.phpt index 3a97c7e910c..901ba188fd2 100644 --- a/sapi/cli/tests/bug65066_100.phpt +++ b/sapi/cli/tests/bug65066_100.phpt @@ -36,4 +36,4 @@ HTTP/1.1 100 Continue Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug65066_422.phpt b/sapi/cli/tests/bug65066_422.phpt index 2552d1d11d9..4e5d31c7a7f 100644 --- a/sapi/cli/tests/bug65066_422.phpt +++ b/sapi/cli/tests/bug65066_422.phpt @@ -36,4 +36,4 @@ HTTP/1.1 422 Unknown Status Code Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug65066_511.phpt b/sapi/cli/tests/bug65066_511.phpt index aa4a9a00306..a0b4eae3931 100644 --- a/sapi/cli/tests/bug65066_511.phpt +++ b/sapi/cli/tests/bug65066_511.phpt @@ -36,4 +36,4 @@ HTTP/1.1 511 Network Authentication Required Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/bug65633.phpt b/sapi/cli/tests/bug65633.phpt index 55834095b18..456436b1f79 100644 --- a/sapi/cli/tests/bug65633.phpt +++ b/sapi/cli/tests/bug65633.phpt @@ -39,7 +39,7 @@ fclose($fp); HTTP/1.1 200 OK Connection: close X-Powered-By: %s -Content-type: text/html +Content-type: text/html; charset=UTF-8 array(1) { ["foo"]=> diff --git a/sapi/cli/tests/php_cli_server_004.phpt b/sapi/cli/tests/php_cli_server_004.phpt index b61f88637e8..8b913f6596c 100644 --- a/sapi/cli/tests/php_cli_server_004.phpt +++ b/sapi/cli/tests/php_cli_server_004.phpt @@ -40,7 +40,7 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(19) "HTTP_HOST:localhost" string(21) "HTTP_USER_AGENT:dummy" diff --git a/sapi/cli/tests/php_cli_server_005.phpt b/sapi/cli/tests/php_cli_server_005.phpt index ccc0f8f3ab0..cdd0ae902fc 100644 --- a/sapi/cli/tests/php_cli_server_005.phpt +++ b/sapi/cli/tests/php_cli_server_005.phpt @@ -52,7 +52,7 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 array(1) { ["userfile"]=> diff --git a/sapi/cli/tests/php_cli_server_006.phpt b/sapi/cli/tests/php_cli_server_006.phpt index 09e7ab07a56..ad6d6c9598b 100644 --- a/sapi/cli/tests/php_cli_server_006.phpt +++ b/sapi/cli/tests/php_cli_server_006.phpt @@ -36,7 +36,7 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(3) "foo" string(3) "bar" diff --git a/sapi/cli/tests/php_cli_server_007.phpt b/sapi/cli/tests/php_cli_server_007.phpt index 64d4df0ed70..6420ff5a412 100644 --- a/sapi/cli/tests/php_cli_server_007.phpt +++ b/sapi/cli/tests/php_cli_server_007.phpt @@ -37,4 +37,4 @@ Host: %s Connection: close X-Powered-By: PHP/%s WWW-Authenticate: Digest realm="foo",qop="auth",nonce="XXXXX",opaque="acbd18db4cc2f85cedef654fccc4a4d8" -Content-type: text/html +Content-type: text/html; charset=UTF-8 diff --git a/sapi/cli/tests/php_cli_server_008.phpt b/sapi/cli/tests/php_cli_server_008.phpt index 2e68e240593..01f825a7461 100644 --- a/sapi/cli/tests/php_cli_server_008.phpt +++ b/sapi/cli/tests/php_cli_server_008.phpt @@ -56,13 +56,13 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(8) "HTTP/1.1" HTTP/1.0 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(8) "HTTP/1.0" diff --git a/sapi/cli/tests/php_cli_server_009.phpt b/sapi/cli/tests/php_cli_server_009.phpt index 2beaeedab6b..231797160f2 100644 --- a/sapi/cli/tests/php_cli_server_009.phpt +++ b/sapi/cli/tests/php_cli_server_009.phpt @@ -80,14 +80,14 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(8) "/foo/bar" HTTP/1.0 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(9) "/foo/bar/" HTTP/1.0 404 Not Found diff --git a/sapi/cli/tests/php_cli_server_010.phpt b/sapi/cli/tests/php_cli_server_010.phpt index 2ef018b8579..30e6d047a71 100644 --- a/sapi/cli/tests/php_cli_server_010.phpt +++ b/sapi/cli/tests/php_cli_server_010.phpt @@ -57,7 +57,7 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(18) "/index.php/foo/bar" string(10) "/index.php" @@ -67,7 +67,7 @@ HTTP/1.0 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(19) "/index.php/foo/bar/" string(10) "/index.php" diff --git a/sapi/cli/tests/php_cli_server_012.phpt b/sapi/cli/tests/php_cli_server_012.phpt index 9a1e60c48b1..302540f7e67 100644 --- a/sapi/cli/tests/php_cli_server_012.phpt +++ b/sapi/cli/tests/php_cli_server_012.phpt @@ -42,7 +42,7 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 Array ( diff --git a/sapi/cli/tests/php_cli_server_015.phpt b/sapi/cli/tests/php_cli_server_015.phpt index 6fb01692440..e3d8c4170db 100644 --- a/sapi/cli/tests/php_cli_server_015.phpt +++ b/sapi/cli/tests/php_cli_server_015.phpt @@ -43,7 +43,7 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8
Fatal error: Call to undefined function non_exists_function() in %ssyntax_error.php on line %s
diff --git a/sapi/cli/tests/php_cli_server_017.phpt b/sapi/cli/tests/php_cli_server_017.phpt index 73530af4807..34e7d5e289e 100644 --- a/sapi/cli/tests/php_cli_server_017.phpt +++ b/sapi/cli/tests/php_cli_server_017.phpt @@ -39,6 +39,6 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: %s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(%d) "%sindex.php" diff --git a/sapi/cli/tests/php_cli_server_018.phpt b/sapi/cli/tests/php_cli_server_018.phpt index deb93487687..44e12929349 100644 --- a/sapi/cli/tests/php_cli_server_018.phpt +++ b/sapi/cli/tests/php_cli_server_018.phpt @@ -39,6 +39,6 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: %s -Content-type: text/html +Content-type: text/html; charset=UTF-8 string(5) "PATCH" diff --git a/sapi/cli/tests/php_cli_server_019.phpt b/sapi/cli/tests/php_cli_server_019.phpt index 2b983e5c0ae..aeb7a9f8916 100644 --- a/sapi/cli/tests/php_cli_server_019.phpt +++ b/sapi/cli/tests/php_cli_server_019.phpt @@ -44,7 +44,7 @@ Host: %s Connection: close X-Powered-By: %s Bar-Foo: Foo -Content-type: text/html +Content-type: text/html; charset=UTF-8 array(2) { ["Host"]=> @@ -64,5 +64,5 @@ array(3) { ["Bar-Foo"]=> string(3) "Foo" ["Content-type"]=> - string(9) "text/html" + string(24) "text/html; charset=UTF-8" } diff --git a/sapi/cli/tests/upload_2G.phpt b/sapi/cli/tests/upload_2G.phpt index b8416ea7309..707eddbad3e 100644 --- a/sapi/cli/tests/upload_2G.phpt +++ b/sapi/cli/tests/upload_2G.phpt @@ -43,7 +43,7 @@ if (!$fp) { } $prev = "----123 -Content-Type: text/plain +Content-Type: text/plain; charset=UTF-8 Content-Disposition: form-data; name=\"file1\"; filename=\"file1.txt\"\n\n"; $post = "\n----123--\n"; $total = $length + strlen($prev) + strlen($post); @@ -79,7 +79,7 @@ HTTP/1.1 200 OK Host: %s Connection: close X-Powered-By: PHP/%s -Content-type: text/html +Content-type: text/html; charset=UTF-8 array(1) { ["file1"]=> diff --git a/tests/basic/encoding.phpt b/tests/basic/encoding.phpt new file mode 100644 index 00000000000..b2ee5f3ca2e --- /dev/null +++ b/tests/basic/encoding.phpt @@ -0,0 +1,39 @@ +--TEST-- +PHP encoding setting test +--INI-- +--FILE-- +