From 226b4b1ef33f81b2c5501501a0ef8edb47446c1c Mon Sep 17 00:00:00 2001 From: Rui Hirokawa Date: Fri, 3 Nov 2006 02:24:50 +0000 Subject: [PATCH] fixed illegal encoding detection when mbstring.encoding_translation is enabled.(made by komura) --- ext/mbstring/mbstring.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 48f2496a71..31cf1f1dd9 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -1013,7 +1013,10 @@ PHP_RINIT_FUNCTION(mbstring) MBSTRG(current_http_output_encoding) = MBSTRG(http_output_encoding); MBSTRG(current_filter_illegal_mode) = MBSTRG(filter_illegal_mode); MBSTRG(current_filter_illegal_substchar) = MBSTRG(filter_illegal_substchar); - MBSTRG(illegalchars) = 0; + + if (!MBSTRG(encoding_translation)) { + MBSTRG(illegalchars) = 0; + } n = 0; if (MBSTRG(detect_order_list)) { @@ -1774,6 +1777,8 @@ MBSTRING_API SAPI_TREAT_DATA_FUNC(mbstr_treat_data) info.num_from_encodings = MBSTRG(http_input_list_size); info.from_language = MBSTRG(language); + MBSTRG(illegalchars) = 0; + detected = php_mbstr_encoding_handler(&info, array_ptr, res TSRMLS_CC); MBSTRG(http_input_identify) = detected; @@ -3864,8 +3869,13 @@ PHP_FUNCTION(mb_check_encoding) if (ret != NULL) { MBSTRG(illegalchars) += illegalchars; - efree(ret->val); - RETURN_BOOL(illegalchars == 0); + if (illegalchars == 0 && strncmp(string.val, ret->val, string.len) == 0) { + efree(ret->val); + RETURN_TRUE; + } else { + efree(ret->val); + RETURN_FALSE; + } } else { RETURN_FALSE; } -- 2.50.1