hirokawa Sun Dec 25 15:23:55 2005 EDT
Modified files: (Branch: PHP_5_1)
/php-src/ext/mbstring mb_gpc.c mbstring.c mbstring.h
/php-src/ext/mbstring/libmbfl/mbfl mbfilter.c mbfilter.h
Log:
MFH: fixed #35711, added mbstring.strict_detection to detect the encoding
striktly.
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mb_gpc.c?r1=1.17&r2=1.17.2.1&diff_format=u
Index: php-src/ext/mbstring/mb_gpc.c
diff -u php-src/ext/mbstring/mb_gpc.c:1.17
php-src/ext/mbstring/mb_gpc.c:1.17.2.1
--- php-src/ext/mbstring/mb_gpc.c:1.17 Wed Aug 3 14:07:24 2005
+++ php-src/ext/mbstring/mb_gpc.c Sun Dec 25 15:23:55 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mb_gpc.c,v 1.17 2005/08/03 14:07:24 sniper Exp $ */
+/* $Id: mb_gpc.c,v 1.17.2.1 2005/12/25 15:23:55 hirokawa Exp $ */
/* {{{ includes */
#ifdef HAVE_CONFIG_H
@@ -266,7 +266,7 @@
} else {
/* auto detect */
from_encoding = mbfl_no_encoding_invalid;
- identd = mbfl_encoding_detector_new((enum mbfl_no_encoding
*)info->from_encodings, info->num_from_encodings);
+ identd = mbfl_encoding_detector_new((enum mbfl_no_encoding
*)info->from_encodings, info->num_from_encodings, MBSTRG(strict_detection));
if (identd) {
n = 0;
while (n < num) {
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.c?r1=1.224.2.9&r2=1.224.2.10&diff_format=u
Index: php-src/ext/mbstring/mbstring.c
diff -u php-src/ext/mbstring/mbstring.c:1.224.2.9
php-src/ext/mbstring/mbstring.c:1.224.2.10
--- php-src/ext/mbstring/mbstring.c:1.224.2.9 Fri Dec 23 11:15:16 2005
+++ php-src/ext/mbstring/mbstring.c Sun Dec 25 15:23:55 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.c,v 1.224.2.9 2005/12/23 11:15:16 hirokawa Exp $ */
+/* $Id: mbstring.c,v 1.224.2.10 2005/12/25 15:23:55 hirokawa Exp $ */
/*
* PHP 4 Multibyte String module "mbstring"
@@ -734,6 +734,9 @@
STD_PHP_INI_BOOLEAN("mbstring.encoding_translation", "0",
PHP_INI_SYSTEM | PHP_INI_PERDIR,
OnUpdate_mbstring_encoding_translation,
encoding_translation, zend_mbstring_globals, mbstring_globals)
+
+ STD_PHP_INI_BOOLEAN("mbstring.strict_detection", "0",
+ PHP_INI_ALL, OnUpdateLong, strict_detection, zend_mbstring_globals,
mbstring_globals)
PHP_INI_END()
/* }}} */
@@ -769,6 +772,7 @@
MBSTRG(current_filter_illegal_substchar) = 0x3f; /* '?' */
MBSTRG(func_overload) = 0;
MBSTRG(encoding_translation) = 0;
+ MBSTRG(strict_detection) = 0;
pglobals->outconv = NULL;
#if HAVE_MBREGEX
_php_mb_regex_globals_ctor(pglobals TSRMLS_CC);
@@ -2022,7 +2026,7 @@
string.no_encoding = from_encoding;
} else if (size > 1) {
/* auto detect */
- from_encoding = mbfl_identify_encoding_no(&string,
list, size);
+ from_encoding = mbfl_identify_encoding_no(&string,
list, size, MBSTRG(strict_detection));
if (from_encoding != mbfl_no_encoding_invalid) {
string.no_encoding = from_encoding;
} else {
@@ -2264,6 +2268,9 @@
convert_to_long_ex(arg_strict);
strict = Z_LVAL_PP(arg_strict);
}
+ else {
+ strict = MBSTRG(strict_detection);
+ }
if (size > 0 && list != NULL) {
elist = list;
@@ -2555,7 +2562,7 @@
stack_max = PHP_MBSTR_STACK_BLOCK_SIZE;
stack = (zval ***)safe_emalloc(stack_max, sizeof(zval **), 0);
stack_level = 0;
- identd = mbfl_encoding_detector_new(elist, elistsz);
+ identd = mbfl_encoding_detector_new(elist, elistsz,
MBSTRG(strict_detection));
if (identd != NULL) {
n = 2;
while (n < argc || stack_level > 0) {
@@ -3174,7 +3181,7 @@
orig_str.no_encoding = MBSTRG(current_internal_encoding);
if (orig_str.no_encoding == mbfl_no_encoding_invalid
|| orig_str.no_encoding == mbfl_no_encoding_pass) {
- orig_str.no_encoding =
mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list),
MBSTRG(current_detect_order_list_size));
+ orig_str.no_encoding =
mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list),
MBSTRG(current_detect_order_list_size), MBSTRG(strict_detection));
}
pstr = mbfl_mime_header_encode(&orig_str, &conv_str, tran_cs,
head_enc, "\n", sizeof("Subject: [PHP-jp nnnnnnnn]"));
if (pstr != NULL) {
@@ -3194,7 +3201,7 @@
if (orig_str.no_encoding == mbfl_no_encoding_invalid
|| orig_str.no_encoding == mbfl_no_encoding_pass) {
- orig_str.no_encoding =
mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list),
MBSTRG(current_detect_order_list_size));
+ orig_str.no_encoding =
mbfl_identify_encoding_no(&orig_str, MBSTRG(current_detect_order_list),
MBSTRG(current_detect_order_list_size), MBSTRG(strict_detection));
}
pstr = NULL;
@@ -3571,7 +3578,7 @@
mbfl_string_init(&string);
string.no_language = MBSTRG(current_language);
- identd = mbfl_encoding_detector_new(elist, size);
+ identd = mbfl_encoding_detector_new(elist, size,
MBSTRG(strict_detection));
if (identd) {
int n = 0;
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/mbstring.h?r1=1.66&r2=1.66.2.1&diff_format=u
Index: php-src/ext/mbstring/mbstring.h
diff -u php-src/ext/mbstring/mbstring.h:1.66
php-src/ext/mbstring/mbstring.h:1.66.2.1
--- php-src/ext/mbstring/mbstring.h:1.66 Wed Aug 3 14:07:24 2005
+++ php-src/ext/mbstring/mbstring.h Sun Dec 25 15:23:55 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mbstring.h,v 1.66 2005/08/03 14:07:24 sniper Exp $ */
+/* $Id: mbstring.h,v 1.66.2.1 2005/12/25 15:23:55 hirokawa Exp $ */
/*
* PHP 4 Multibyte String module "mbstring" (currently only for Japanese)
@@ -180,6 +180,7 @@
int current_filter_illegal_substchar;
long func_overload;
zend_bool encoding_translation;
+ long strict_detection;
mbfl_buffer_converter *outconv;
#if HAVE_MBREGEX && defined(PHP_MBREGEX_GLOBALS)
PHP_MBREGEX_GLOBALS
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c?r1=1.7.2.2&r2=1.7.2.3&diff_format=u
Index: php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c
diff -u php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c:1.7.2.2
php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c:1.7.2.3
--- php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c:1.7.2.2 Sat Dec 24
04:32:42 2005
+++ php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c Sun Dec 25 15:23:55 2005
@@ -336,7 +336,7 @@
* encoding detector
*/
mbfl_encoding_detector *
-mbfl_encoding_detector_new(enum mbfl_no_encoding *elist, int elistsz)
+mbfl_encoding_detector_new(enum mbfl_no_encoding *elist, int elistsz, int
strict)
{
mbfl_encoding_detector *identd;
@@ -371,6 +371,9 @@
}
identd->filter_list_size = num;
+ /* set strict flag */
+ identd->strict = strict;
+
return identd;
}
@@ -441,10 +444,24 @@
while (n >= 0) {
filter = identd->filter_list[n];
if (!filter->flag) {
+ if (identd->strict && filter->status) {
+ continue;
+ }
encoding = filter->encoding->no_encoding;
}
n--;
}
+
+ if (encoding == mbfl_no_encoding_invalid) {
+ n = identd->filter_list_size - 1;
+ while (n >= 0) {
+ filter = identd->filter_list[n];
+ if (!filter->flag) {
+ encoding =
filter->encoding->no_encoding;
+ }
+ n--;
+ }
+ }
}
return encoding;
@@ -622,11 +639,11 @@
}
enum mbfl_no_encoding
-mbfl_identify_encoding_no(mbfl_string *string, enum mbfl_no_encoding *elist,
int elistsz)
+mbfl_identify_encoding_no(mbfl_string *string, enum mbfl_no_encoding *elist,
int elistsz, int strict)
{
const mbfl_encoding *encoding;
- encoding = mbfl_identify_encoding(string, elist, elistsz, 0);
+ encoding = mbfl_identify_encoding(string, elist, elistsz, strict);
if (encoding != NULL &&
encoding->no_encoding > mbfl_no_encoding_charset_min &&
encoding->no_encoding < mbfl_no_encoding_charset_max) {
http://cvs.php.net/viewcvs.cgi/php-src/ext/mbstring/libmbfl/mbfl/mbfilter.h?r1=1.4&r2=1.4.2.1&diff_format=u
Index: php-src/ext/mbstring/libmbfl/mbfl/mbfilter.h
diff -u php-src/ext/mbstring/libmbfl/mbfl/mbfilter.h:1.4
php-src/ext/mbstring/libmbfl/mbfl/mbfilter.h:1.4.2.1
--- php-src/ext/mbstring/libmbfl/mbfl/mbfilter.h:1.4 Wed Feb 23 13:35:34 2005
+++ php-src/ext/mbstring/libmbfl/mbfl/mbfilter.h Sun Dec 25 15:23:55 2005
@@ -138,9 +138,10 @@
struct _mbfl_encoding_detector {
mbfl_identify_filter **filter_list;
int filter_list_size;
+ int strict;
};
-MBFLAPI extern mbfl_encoding_detector * mbfl_encoding_detector_new(enum
mbfl_no_encoding *elist, int elistsz);
+MBFLAPI extern mbfl_encoding_detector * mbfl_encoding_detector_new(enum
mbfl_no_encoding *elist, int elistsz, int strict);
MBFLAPI extern void mbfl_encoding_detector_delete(mbfl_encoding_detector
*identd);
MBFLAPI extern int mbfl_encoding_detector_feed(mbfl_encoding_detector *identd,
mbfl_string *string);
MBFLAPI extern enum mbfl_no_encoding
mbfl_encoding_detector_judge(mbfl_encoding_detector *identd);
@@ -163,7 +164,7 @@
mbfl_identify_encoding_name(mbfl_string *string, enum mbfl_no_encoding *elist,
int elistsz, int strict);
MBFLAPI extern enum mbfl_no_encoding
-mbfl_identify_encoding_no(mbfl_string *string, enum mbfl_no_encoding *elist,
int elistsz);
+mbfl_identify_encoding_no(mbfl_string *string, enum mbfl_no_encoding *elist,
int elistsz, int strict);
/*
* strlen
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php