Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16864 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56100 invoked by uid 1010); 22 Jun 2005 21:28:09 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 56085 invoked from network); 22 Jun 2005 21:28:09 -0000 Received: from unknown (HELO pb1.pair.com) (127.0.0.1) by localhost with SMTP; 22 Jun 2005 21:28:09 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:57027] helo=mail.zend.com) by pb1.pair.com (ecelerity 1.2 r(5656M)) with SMTP id 8F/C0-22648-7E7D9B24 for ; Wed, 22 Jun 2005 17:28:08 -0400 Received: (qmail 31605 invoked from network); 22 Jun 2005 21:28:02 -0000 Received: from internal.zend.office (HELO int.zend.com) (10.1.1.1) by internal.zend.office with SMTP; 22 Jun 2005 21:28:02 -0000 Date: Thu, 23 Jun 2005 01:28:04 +0400 To: internals@lists.php.net Cc: Andi Gutmans Message-ID: <20050623012804.541630ea.antony@zend.com> X-Mailer: Sylpheed version 2.0.0beta2 (GTK+ 2.6.4; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Thu__23_Jun_2005_01_28_04_+0400_XWC6=AQ6V1FK=sVS" Subject: [PATCH] bugfix for #29983 (unable to set default_charset using ini_set) From: antony@zend.com (Antony Dovgal) --Multipart=_Thu__23_Jun_2005_01_28_04_+0400_XWC6=AQ6V1FK=sVS Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hello all, hello Andi. Andi, I'd like to ask your permission to commit the patch for http://bugs.php.net/bug.php?id=29983 It adds OnUpdateDefaultCharset, which calls sapi_header_op() (only in runtime) to substitute SAPI content-type/charset header. See the patch in attachment. -- Wbr, Antony Dovgal --Multipart=_Thu__23_Jun_2005_01_28_04_+0400_XWC6=AQ6V1FK=sVS Content-Type: text/plain; name="default_charset.diff.txt" Content-Disposition: attachment; filename="default_charset.diff.txt" Content-Transfer-Encoding: 7bit Index: main/main.c =================================================================== RCS file: /repository/php-src/main/main.c,v retrieving revision 1.634 diff -u -p -d -r1.634 main.c --- main/main.c 20 Jun 2005 19:58:51 -0000 1.634 +++ main/main.c 22 Jun 2005 21:22:18 -0000 @@ -207,6 +207,43 @@ static PHP_INI_MH(OnUpdateTimeout) } /* }}} */ +/* {{{ PHP_INI_MH + */ +static PHP_INI_MH(OnUpdateDefaultCharset) +{ + if (stage == PHP_INI_STAGE_RUNTIME) { + sapi_header_line ctr = {0}; + int mimetype_len = SG(default_mimetype) ? strlen(SG(default_mimetype)) : 0; + + if (new_value_length) { + ctr.line = emalloc( sizeof("Content-type: ")-1 + mimetype_len + sizeof("; charset=")-1 + new_value_length + 1); + + memcpy(ctr.line, "Content-type: ", sizeof("Content-type: ")); + memcpy(ctr.line + sizeof("Content-type: ")-1, SG(default_mimetype), mimetype_len); + memcpy(ctr.line + sizeof("Content-type: ")-1 + mimetype_len, "; charset=", sizeof("; charset=")); + memcpy(ctr.line + sizeof("Content-type: ")-1 + mimetype_len + sizeof("; charset=")-1, new_value, new_value_length); + + ctr.line_len = sizeof("Content-type: ")-1 + mimetype_len + sizeof("; charset=")-1 + new_value_length; + } + else { + ctr.line = emalloc( sizeof("Content-type: ")-1 + mimetype_len + 1); + + memcpy(ctr.line, "Content-type: ", sizeof("Content-type: ")); + memcpy(ctr.line + sizeof("Content-type: ")-1, SG(default_mimetype), mimetype_len); + + ctr.line_len = sizeof("Content-type: ")-1 + mimetype_len; + } + ctr.line[ctr.line_len] = 0; + + sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC); + efree(ctr.line); + } + + OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + return SUCCESS; +} +/* }}} */ + /* Need to convert to strings and make use of: * PHP_SAFE_MODE * @@ -287,8 +324,8 @@ 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", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateString, 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("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateDefaultCharset, default_charset, sapi_globals_struct,sapi_globals) STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateString, error_log, php_core_globals, core_globals) STD_PHP_INI_ENTRY("extension_dir", PHP_EXTENSION_DIR, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals) STD_PHP_INI_ENTRY("include_path", PHP_INCLUDE_PATH, PHP_INI_ALL, OnUpdateStringUnempty, include_path, php_core_globals, core_globals) --Multipart=_Thu__23_Jun_2005_01_28_04_+0400_XWC6=AQ6V1FK=sVS--