From: Alex Dowad Date: Wed, 7 Oct 2020 20:30:34 +0000 (+0200) Subject: Don't pass invalid JIS X 0212, JIS X 0213, and Windows-CP932 characters through X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ffcf563bd184316c988fe3fa09a261e96999edd;p=php Don't pass invalid JIS X 0212, JIS X 0213, and Windows-CP932 characters through Similarly to JIS X 0208, mbstring would pass kuten codes which are not mapped in the JIS X 0212, JIS X 0213, or CP932 character sets through silently when converting to another Japanese encoding. --- diff --git a/ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c b/ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c index b630d3fcb0..3f4fb7132c 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c @@ -383,9 +383,8 @@ retry: int mbfl_filt_conv_wchar_jis_ms(int c, mbfl_convert_filter *filter) { - int c1, s; + int s = 0; - s = 0; if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) { s = ucs_a1_jis_table[c - ucs_a1_jis_table_min]; } else if (c >= ucs_a2_jis_table_min && c < ucs_a2_jis_table_max) { @@ -408,11 +407,7 @@ mbfl_filt_conv_wchar_jis_ms(int c, mbfl_convert_filter *filter) /* do some transliteration */ if (s <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_JIS0212) { - s = c & MBFL_WCSPLANE_MASK; - s |= 0x8080; - } else if (c == 0xa5) { /* YEN SIGN */ + if (c == 0xa5) { /* YEN SIGN */ s = 0x1005c; } else if (c == 0x203e) { /* OVER LINE */ s = 0x1007e; diff --git a/ext/mbstring/libmbfl/filters/mbfilter_cp51932.c b/ext/mbstring/libmbfl/filters/mbfilter_cp51932.c index 25944a10dd..6e0746b866 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_cp51932.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_cp51932.c @@ -210,13 +210,7 @@ mbfl_filt_conv_wchar_cp51932(int c, mbfl_convert_filter *filter) } if (s1 >= 0x8080) s1 = -1; /* we don't support JIS X0213 */ if (s1 <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_WINCP932) { - s1 = c & MBFL_WCSPLANE_MASK; - if (s1 >= ((85 + 0x20) << 8)) { /* 85ku - 120ku */ - s1 = -1; - } - } else if (c == 0xa5) { /* YEN SIGN */ + if (c == 0xa5) { /* YEN SIGN */ s1 = 0x005c; /* YEN SIGN */ } else if (c == 0x203e) { /* OVER LINE */ s1 = 0x007e; /* FULLWIDTH MACRON */ diff --git a/ext/mbstring/libmbfl/filters/mbfilter_cp932.c b/ext/mbstring/libmbfl/filters/mbfilter_cp932.c index 64ccd57361..6246600de8 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_cp932.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_cp932.c @@ -251,14 +251,7 @@ mbfl_filt_conv_wchar_cp932(int c, mbfl_convert_filter *filter) s2 = 1; } if (s1 <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_WINCP932) { - s1 = c & MBFL_WCSPLANE_MASK; - s2 = 1; - } else if (c1 == MBFL_WCSPLANE_JIS0212) { - s1 = c & MBFL_WCSPLANE_MASK; - s1 |= 0x8080; - } else if (c == 0xa5) { /* YEN SIGN */ + if (c == 0xa5) { /* YEN SIGN */ s1 = 0x005c; /* YEN SIGN */ } else if (c == 0x203e) { /* OVER LINE */ s1 = 0x007e; /* FULLWIDTH MACRON */ diff --git a/ext/mbstring/libmbfl/filters/mbfilter_euc_jp.c b/ext/mbstring/libmbfl/filters/mbfilter_euc_jp.c index 1589ae7966..507a26a5b1 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_euc_jp.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_euc_jp.c @@ -192,9 +192,8 @@ static int mbfl_filt_conv_eucjp_wchar_flush(mbfl_convert_filter *filter) int mbfl_filt_conv_wchar_eucjp(int c, mbfl_convert_filter *filter) { - int s; + int s = 0; - s = 0; if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) { s = ucs_a1_jis_table[c - ucs_a1_jis_table_min]; } else if (c >= ucs_a2_jis_table_min && c < ucs_a2_jis_table_max) { diff --git a/ext/mbstring/libmbfl/filters/mbfilter_euc_jp_win.c b/ext/mbstring/libmbfl/filters/mbfilter_euc_jp_win.c index df51be0183..569dabd92d 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_euc_jp_win.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_euc_jp_win.c @@ -273,20 +273,7 @@ mbfl_filt_conv_wchar_eucjpwin(int c, mbfl_convert_filter *filter) s1 = 0x2d62; /* NUMERO SIGN */ } if (s1 <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_WINCP932) { - s1 = c & MBFL_WCSPLANE_MASK; - if (s1 >= ((85 + 0x20) << 8)) { /* 85ku - 120ku */ - s1 = -1; - } - } else if (c1 == MBFL_WCSPLANE_JIS0212) { - s1 = c & MBFL_WCSPLANE_MASK; - if (s1 >= ((83 + 0x20) << 8)) { /* 83ku - 94ku */ - s1 = -1; - } else { - s1 |= 0x8080; - } - } else if (c == 0xa5) { /* YEN SIGN */ + if (c == 0xa5) { /* YEN SIGN */ s1 = 0x216f; /* FULLWIDTH YEN SIGN */ } else if (c == 0x203e) { /* OVER LINE */ s1 = 0x2131; /* FULLWIDTH MACRON */ diff --git a/ext/mbstring/libmbfl/filters/mbfilter_iso2022_jp_ms.c b/ext/mbstring/libmbfl/filters/mbfilter_iso2022_jp_ms.c index af54a1c605..5e0a63958b 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_iso2022_jp_ms.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_iso2022_jp_ms.c @@ -302,14 +302,7 @@ mbfl_filt_conv_wchar_2022jpms(int c, mbfl_convert_filter *filter) s1 = (c1 << 8) | c2; } if (s1 <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_WINCP932) { - s1 = c & MBFL_WCSPLANE_MASK; - s2 = 1; - } else if (c1 == MBFL_WCSPLANE_JIS0212) { - s1 = c & MBFL_WCSPLANE_MASK; - s1 |= 0x8080; - } else if (c == 0xa5) { /* YEN SIGN */ + if (c == 0xa5) { /* YEN SIGN */ s1 = 0x216f; /* FULLWIDTH YEN SIGN */ } else if (c == 0x203e) { /* OVER LINE */ s1 = 0x2131; /* FULLWIDTH MACRON */ diff --git a/ext/mbstring/libmbfl/filters/mbfilter_iso2022jp_mobile.c b/ext/mbstring/libmbfl/filters/mbfilter_iso2022jp_mobile.c index 1b4857dfe2..0099fb1ebb 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_iso2022jp_mobile.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_iso2022jp_mobile.c @@ -330,14 +330,7 @@ mbfl_filt_conv_wchar_2022jp_mobile(int c, mbfl_convert_filter *filter) s1 = (c1 << 8) | c2; } if (s1 <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_WINCP932) { - s1 = c & MBFL_WCSPLANE_MASK; - s2 = 1; - } else if (c1 == MBFL_WCSPLANE_JIS0212) { - s1 = c & MBFL_WCSPLANE_MASK; - s1 |= 0x8080; - } else if (c == 0xa5) { /* YEN SIGN */ + if (c == 0xa5) { /* YEN SIGN */ s1 = 0x216f; /* FULLWIDTH YEN SIGN */ } else if (c == 0x203e) { /* OVER LINE */ s1 = 0x2131; /* FULLWIDTH MACRON */ diff --git a/ext/mbstring/libmbfl/filters/mbfilter_jis.c b/ext/mbstring/libmbfl/filters/mbfilter_jis.c index 8ba46a5b9a..5e0c05c8fc 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_jis.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_jis.c @@ -274,9 +274,8 @@ retry: int mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter) { - int c1, s; + int s = 0; - s = 0; if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) { s = ucs_a1_jis_table[c - ucs_a1_jis_table_min]; } else if (c >= ucs_a2_jis_table_min && c < ucs_a2_jis_table_max) { @@ -287,11 +286,7 @@ mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter) s = ucs_r_jis_table[c - ucs_r_jis_table_min]; } if (s <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_JIS0212) { - s = c & MBFL_WCSPLANE_MASK; - s |= 0x8080; - } else if (c == 0xa5) { /* YEN SIGN */ + if (c == 0xa5) { /* YEN SIGN */ s = 0x1005c; } else if (c == 0x203e) { /* OVER LINE */ s = 0x1007e; diff --git a/ext/mbstring/libmbfl/filters/mbfilter_sjis_2004.c b/ext/mbstring/libmbfl/filters/mbfilter_sjis_2004.c index 02bbdccdc8..1e549fdebb 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_sjis_2004.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_sjis_2004.c @@ -590,10 +590,6 @@ retry: } if (s1 <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_JIS0213) { - s1 = c & MBFL_WCSPLANE_MASK; - } if (c == 0) { s1 = 0; } else if (s1 <= 0) { diff --git a/ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c b/ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c index 6361195606..4dead25a78 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_sjis_mac.c @@ -416,14 +416,7 @@ mbfl_filt_conv_wchar_sjis_mac(int c, mbfl_convert_filter *filter) } if (s1 <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_WINCP932) { - s1 = c & MBFL_WCSPLANE_MASK; - s2 = 1; - } else if (c1 == MBFL_WCSPLANE_JIS0212) { - s1 = c & MBFL_WCSPLANE_MASK; - s1 |= 0x8080; - } else if (c == 0xa0) { + if (c == 0xa0) { s1 = 0x00a0; } else if (c == 0xa5) { /* YEN SIGN */ /* Unicode has codepoint 0xFFE5 for a fullwidth Yen sign; diff --git a/ext/mbstring/libmbfl/filters/mbfilter_sjis_mobile.c b/ext/mbstring/libmbfl/filters/mbfilter_sjis_mobile.c index 10ac7d9ce4..a434d9bf54 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_sjis_mobile.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_sjis_mobile.c @@ -790,14 +790,7 @@ mbfl_filt_conv_wchar_sjis_mobile(int c, mbfl_convert_filter *filter) s2 = 1; } if (s1 <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_WINCP932) { - s1 = c & MBFL_WCSPLANE_MASK; - s2 = 1; - } else if (c1 == MBFL_WCSPLANE_JIS0212) { - s1 = c & MBFL_WCSPLANE_MASK; - s1 |= 0x8080; - } else if (c == 0xa5) { /* YEN SIGN */ + if (c == 0xa5) { /* YEN SIGN */ s1 = 0x216f; /* FULLWIDTH YEN SIGN */ } else if (c == 0x203e) { /* OVER LINE */ s1 = 0x2131; /* FULLWIDTH MACRON */ diff --git a/ext/mbstring/libmbfl/filters/mbfilter_sjis_open.c b/ext/mbstring/libmbfl/filters/mbfilter_sjis_open.c index ea19e6b105..d1dd5efd95 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_sjis_open.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_sjis_open.c @@ -241,14 +241,7 @@ mbfl_filt_conv_wchar_sjis_open(int c, mbfl_convert_filter *filter) s2 = 1; } if (s1 <= 0) { - c1 = c & ~MBFL_WCSPLANE_MASK; - if (c1 == MBFL_WCSPLANE_WINCP932) { - s1 = c & MBFL_WCSPLANE_MASK; - s2 = 1; - } else if (c1 == MBFL_WCSPLANE_JIS0212) { - s1 = c & MBFL_WCSPLANE_MASK; - s1 |= 0x8080; - } else if (c == 0xa5) { /* YEN SIGN */ + if (c == 0xa5) { /* YEN SIGN */ s1 = 0x216f; /* FULLWIDTH YEN SIGN */ } else if (c == 0x203e) { /* OVER LINE */ s1 = 0x2131; /* FULLWIDTH MACRON */