Browse Source

fixed illegal encoding detection when mbstring.encoding_translation is enabled.(made by komura)

experimental/5.2-WITH_DRCP
Rui Hirokawa 20 years ago
parent
commit
501025306c
  1. 3
      ext/mbstring/mb_gpc.c
  2. 14
      ext/mbstring/mbstring.c

3
ext/mbstring/mb_gpc.c

@ -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) {

14
ext/mbstring/mbstring.c

@ -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;
}

Loading…
Cancel
Save