dmitry Mon Aug 22 10:48:27 2005 EDT
Modified files:
/php-src/main/streams streams.c
Log:
Don't apply "unicode" filters in non-unicode mode
http://cvs.php.net/diff.php/php-src/main/streams/streams.c?r1=1.86&r2=1.87&ty=u
Index: php-src/main/streams/streams.c
diff -u php-src/main/streams/streams.c:1.86 php-src/main/streams/streams.c:1.87
--- php-src/main/streams/streams.c:1.86 Sun Aug 14 09:48:29 2005
+++ php-src/main/streams/streams.c Mon Aug 22 10:48:25 2005
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: streams.c,v 1.86 2005/08/14 13:48:29 wez Exp $ */
+/* $Id: streams.c,v 1.87 2005/08/22 14:48:25 dmitry Exp $ */
#define _GNU_SOURCE
#include "php.h"
@@ -2441,42 +2441,44 @@
}
/* Output encoding on text mode streams defaults to utf8 unless
specified in context parameter */
- if (stream && strchr(implicit_mode, 't') && (strchr(implicit_mode, 'w')
|| strchr(implicit_mode, 'a') || strchr(implicit_mode, '+'))) {
- php_stream_filter *filter;
- char *encoding = (context && context->output_encoding) ?
context->output_encoding : "utf8";
- char *filtername;
- int encoding_len = strlen(encoding);
-
- filtername = emalloc(encoding_len + sizeof("unicode.to."));
- memcpy(filtername, "unicode.to.", sizeof("unicode.to.") - 1);
- memcpy(filtername + sizeof("unicode.to.") - 1, encoding,
encoding_len + 1);
-
- filter = php_stream_filter_create(filtername, NULL, persistent
TSRMLS_CC);
- if (!filter) {
- php_stream_wrapper_log_error(wrapper, options
TSRMLS_CC, "Failed applying output encoding");
- } else {
- php_stream_filter_append(&stream->writefilters, filter);
+ if (stream && strchr(implicit_mode, 't') && UG(unicode)) {
+ if (strchr(implicit_mode, 'w') || strchr(implicit_mode, 'a') ||
strchr(implicit_mode, '+')) {
+ php_stream_filter *filter;
+ char *encoding = (context && context->output_encoding)
? context->output_encoding : "utf8";
+ char *filtername;
+ int encoding_len = strlen(encoding);
+
+ filtername = emalloc(encoding_len +
sizeof("unicode.to."));
+ memcpy(filtername, "unicode.to.", sizeof("unicode.to.")
- 1);
+ memcpy(filtername + sizeof("unicode.to.") - 1,
encoding, encoding_len + 1);
+
+ filter = php_stream_filter_create(filtername, NULL,
persistent TSRMLS_CC);
+ if (!filter) {
+ php_stream_wrapper_log_error(wrapper, options
TSRMLS_CC, "Failed applying output encoding");
+ } else {
+ php_stream_filter_append(&stream->writefilters,
filter);
+ }
+ efree(filtername);
}
- efree(filtername);
- }
-
- if (stream && strchr(implicit_mode, 't') && (strchr(implicit_mode, 'r')
|| strchr(implicit_mode, '+'))) {
- php_stream_filter *filter;
- char *filtername;
- char *encoding = (context && context->input_encoding) ?
context->input_encoding : "utf8";
- int input_encoding_len = strlen(encoding);
- filtername = emalloc(input_encoding_len +
sizeof("unicode.from."));
- memcpy(filtername, "unicode.from.", sizeof("unicode.from.") -
1);
- memcpy(filtername + sizeof("unicode.from.") - 1, encoding,
input_encoding_len + 1);
-
- filter = php_stream_filter_create(filtername, NULL, persistent
TSRMLS_CC);
- if (!filter) {
- php_stream_wrapper_log_error(wrapper, options
TSRMLS_CC, "Failed applying input encoding");
- } else {
- php_stream_filter_append(&stream->readfilters, filter);
+ if (strchr(implicit_mode, 'r') || strchr(implicit_mode, '+')) {
+ php_stream_filter *filter;
+ char *filtername;
+ char *encoding = (context && context->input_encoding) ?
context->input_encoding : "utf8";
+ int input_encoding_len = strlen(encoding);
+
+ filtername = emalloc(input_encoding_len +
sizeof("unicode.from."));
+ memcpy(filtername, "unicode.from.",
sizeof("unicode.from.") - 1);
+ memcpy(filtername + sizeof("unicode.from.") - 1,
encoding, input_encoding_len + 1);
+
+ filter = php_stream_filter_create(filtername, NULL,
persistent TSRMLS_CC);
+ if (!filter) {
+ php_stream_wrapper_log_error(wrapper, options
TSRMLS_CC, "Failed applying input encoding");
+ } else {
+ php_stream_filter_append(&stream->readfilters,
filter);
+ }
+ efree(filtername);
}
- efree(filtername);
}
if (stream == NULL && (options & REPORT_ERRORS)) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php