]> 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:26:50 +0000 (02:26 +0000)
committerRui Hirokawa <hirokawa@php.net>
Fri, 3 Nov 2006 02:26:50 +0000 (02:26 +0000)
ext/mbstring/mb_gpc.c
ext/mbstring/mbstring.c

index 8cfe56a4d14c29c4b652520bf82913ca189fd31f..4508a97553c81ff3902cba32983fb9b8b0bd5f49 100644 (file)
@@ -154,6 +154,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_mb_encoding_handler_ex(&info, array_ptr, res TSRMLS_CC);
        MBSTRG(http_input_identify) = detected;
 
@@ -346,6 +348,7 @@ out:
        }
 
        if (convd != NULL) {
+               MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
                mbfl_buffer_converter_delete(convd);
        }
        if (val_list != NULL) {
index 77ce2c07f241d1ca6b9b7dd027ca22bd19fdb2a7..dbf27b77a2b8297590fc2bbfd6fbcfef284d1d3a 100644 (file)
@@ -933,7 +933,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)) {
@@ -4053,8 +4056,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;
        }