]> granicus.if.org Git - php/commitdiff
fixed illegal encoding detection when mbstring.encoding_translation is enabled.(made...
authorRui Hirokawa <hirokawa@php.net>
Fri, 3 Nov 2006 02:24:50 +0000 (02:24 +0000)
committerRui Hirokawa <hirokawa@php.net>
Fri, 3 Nov 2006 02:24:50 +0000 (02:24 +0000)
ext/mbstring/mbstring.c

index 48f2496a71dade6b9cd7198f594ccc6f67302557..31cf1f1dd90de85ed314d42ff0974cf2281f63d5 100644 (file)
@@ -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;
        }