1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 18:53:33 +02:00

added support "entity" as substitute_character settin accoding to bug #39404

This commit is contained in:
Rui Hirokawa
2007-09-24 11:50:54 +00:00
parent 4d9ca5ef3c
commit 9fb312447e
3 changed files with 21 additions and 1 deletions
+1
View File
@@ -104,6 +104,7 @@
#define MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE 0
#define MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR 1
#define MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG 2
#define MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY 3
/*
* buffering converter
+9 -1
View File
@@ -386,9 +386,14 @@ mbfl_filt_conv_illegal_output(int c, mbfl_convert_filter *filter)
ret = (*filter->filter_function)(filter->illegal_substchar, filter);
break;
case MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG:
case MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY:
if (c >= 0) {
if (c < MBFL_WCSGROUP_UCS4MAX) { /* unicode */
ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"U+");
if (mode_backup == MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG) {
ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"U+");
} else { /* entity */
ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)"&#");
}
} else {
if (c < MBFL_WCSGROUP_WCHARMAX) {
m = c & ~MBFL_WCSPLANE_MASK;
@@ -432,6 +437,9 @@ mbfl_filt_conv_illegal_output(int c, mbfl_convert_filter *filter)
if (m == 0 && ret >= 0) {
ret = (*filter->filter_function)(mbfl_hexchar_table[0], filter);
}
if (mode_backup == MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY) {
ret = mbfl_convert_filter_strcat(filter, (const unsigned char *)";");
}
}
}
break;
+11
View File
@@ -716,6 +716,9 @@ static PHP_INI_MH(OnUpdate_mbstring_substitute_character)
} else if (strcasecmp("long", new_value) == 0) {
MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG;
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG;
} else if (strcasecmp("entity", new_value) == 0) {
MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY;
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY;
} else {
MBSTRG(filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
@@ -1328,6 +1331,8 @@ PHP_FUNCTION(mb_substitute_character)
RETVAL_STRING("none", 1);
} else if (MBSTRG(current_filter_illegal_mode) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG) {
RETVAL_STRING("long", 1);
} else if (MBSTRG(current_filter_illegal_mode) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY) {
RETVAL_STRING("entity", 1);
} else {
RETVAL_LONG(MBSTRG(current_filter_illegal_substchar));
}
@@ -1339,6 +1344,8 @@ PHP_FUNCTION(mb_substitute_character)
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE;
} else if (strcasecmp("long", Z_STRVAL_PP(arg1)) == 0) {
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG;
} else if (strcasecmp("entity", Z_STRVAL_PP(arg1)) == 0) {
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY;
} else {
convert_to_long_ex(arg1);
if (Z_LVAL_PP(arg1)< 0xffff && Z_LVAL_PP(arg1)> 0x0) {
@@ -3905,6 +3912,8 @@ PHP_FUNCTION(mb_get_info)
add_assoc_string(return_value, "substitute_character", "none", 1);
} else if (MBSTRG(current_filter_illegal_mode) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG) {
add_assoc_string(return_value, "substitute_character", "long", 1);
} else if (MBSTRG(current_filter_illegal_mode) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY) {
add_assoc_string(return_value, "substitute_character", "entity", 1);
} else {
add_assoc_long(return_value, "substitute_character", MBSTRG(current_filter_illegal_substchar));
}
@@ -3999,6 +4008,8 @@ PHP_FUNCTION(mb_get_info)
RETVAL_STRING("none", 1);
} else if (MBSTRG(current_filter_illegal_mode) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG) {
RETVAL_STRING("long", 1);
} else if (MBSTRG(current_filter_illegal_mode) == MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY) {
RETVAL_STRING("entity", 1);
} else {
RETVAL_LONG(MBSTRG(current_filter_illegal_substchar));
}