summaryrefslogtreecommitdiff
path: root/ext/mbstring
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mbstring')
-rw-r--r--ext/mbstring/config.m43
-rw-r--r--ext/mbstring/libmbfl/filters/Makefile.am2
-rw-r--r--ext/mbstring/libmbfl/filters/mbfilter_euc_jp_win.c3
-rw-r--r--ext/mbstring/libmbfl/filters/mbfilter_jis.c154
-rw-r--r--ext/mbstring/libmbfl/filters/mbfilter_jis.h4
-rw-r--r--ext/mbstring/libmbfl/filters/unicode_table_jis.h14
-rw-r--r--ext/mbstring/libmbfl/mbfl/mbfilter.c2
-rw-r--r--ext/mbstring/libmbfl/mbfl/mbfl_convert.c5
-rw-r--r--ext/mbstring/libmbfl/mbfl/mbfl_encoding.c3
-rw-r--r--ext/mbstring/libmbfl/mbfl/mbfl_encoding.h2
-rw-r--r--ext/mbstring/libmbfl/mbfl/mbfl_ident.c1
-rw-r--r--ext/mbstring/mb_gpc.c3
-rw-r--r--ext/mbstring/mbstring.c118
13 files changed, 263 insertions, 51 deletions
diff --git a/ext/mbstring/config.m4 b/ext/mbstring/config.m4
index c57f13cf06..e0698a2d62 100644
--- a/ext/mbstring/config.m4
+++ b/ext/mbstring/config.m4
@@ -171,6 +171,7 @@ AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [
libmbfl/filters/mbfilter_euc_cn.c
libmbfl/filters/mbfilter_euc_jp.c
libmbfl/filters/mbfilter_euc_jp_win.c
+ libmbfl/filters/mbfilter_cp51932.c
libmbfl/filters/mbfilter_euc_kr.c
libmbfl/filters/mbfilter_euc_tw.c
libmbfl/filters/mbfilter_htmlent.c
@@ -282,7 +283,7 @@ if test "$PHP_MBSTRING" != "no"; then
dnl libmbfl is required
PHP_MBSTRING_SETUP_LIBMBFL
PHP_MBSTRING_EXTENSION
- PHP_INSTALL_HEADERS([ext/mbstring], [mbstring.h php_mbregex.h libmbfl/ libmbfl/mbfl/ oniguruma/])
+ PHP_INSTALL_HEADERS([ext/mbstring], [mbstring.h php_mbregex.h libmbfl/config.h libmbfl/mbfl/eaw_table.h libmbfl/mbfl/mbfilter.h libmbfl/mbfl/mbfilter_8bit.h libmbfl/mbfl/mbfilter_pass.h libmbfl/mbfl/mbfilter_wchar.h libmbfl/mbfl/mbfl_allocators.h libmbfl/mbfl/mbfl_consts.h libmbfl/mbfl/mbfl_convert.h libmbfl/mbfl/mbfl_defs.h libmbfl/mbfl/mbfl_encoding.h libmbfl/mbfl/mbfl_filter_output.h libmbfl/mbfl/mbfl_ident.h libmbfl/mbfl/mbfl_language.h libmbfl/mbfl/mbfl_memory_device.h libmbfl/mbfl/mbfl_string.h oniguruma/oniguruma.h oniguruma/php_onig_compat.h])
fi
# vim600: sts=2 sw=2 et
diff --git a/ext/mbstring/libmbfl/filters/Makefile.am b/ext/mbstring/libmbfl/filters/Makefile.am
index 0c71c8604b..9b2fda4c39 100644
--- a/ext/mbstring/libmbfl/filters/Makefile.am
+++ b/ext/mbstring/libmbfl/filters/Makefile.am
@@ -2,7 +2,7 @@ EXTRA_DIST=Makefile.bcc32 mk_sb_tbl.awk
noinst_LTLIBRARIES=libmbfl_filters.la
INCLUDES=-I../mbfl
libmbfl_filters_la_LDFLAGS=-version-info $(SHLIB_VERSION)
-libmbfl_filters_la_SOURCES=mbfilter_cp936.c mbfilter_hz.c mbfilter_euc_tw.c mbfilter_big5.c mbfilter_euc_jp.c mbfilter_jis.c mbfilter_iso8859_1.c mbfilter_iso8859_2.c mbfilter_cp1252.c mbfilter_cp1251.c mbfilter_ascii.c mbfilter_iso8859_3.c mbfilter_iso8859_4.c mbfilter_iso8859_5.c mbfilter_iso8859_6.c mbfilter_iso8859_7.c mbfilter_iso8859_8.c mbfilter_iso8859_9.c mbfilter_iso8859_10.c mbfilter_iso8859_13.c mbfilter_iso8859_14.c mbfilter_iso8859_15.c mbfilter_iso8859_16.c mbfilter_htmlent.c mbfilter_byte2.c mbfilter_byte4.c mbfilter_uuencode.c mbfilter_base64.c mbfilter_sjis.c mbfilter_7bit.c mbfilter_qprint.c mbfilter_ucs4.c mbfilter_ucs2.c mbfilter_utf32.c mbfilter_utf16.c mbfilter_utf8.c mbfilter_utf7.c mbfilter_utf7imap.c mbfilter_euc_jp_win.c mbfilter_cp932.c mbfilter_euc_cn.c mbfilter_euc_kr.c mbfilter_uhc.c mbfilter_iso2022_kr.c mbfilter_cp866.c mbfilter_koi8r.c mbfilter_armscii8.c html_entities.c cp932_table.h html_entities.h mbfilter_7bit.h mbfilter_ascii.h mbfilter_base64.h mbfilter_big5.h mbfilter_byte2.h mbfilter_byte4.h mbfilter_cp1251.h mbfilter_cp1252.h mbfilter_cp866.h mbfilter_cp932.h mbfilter_cp936.h mbfilter_euc_cn.h mbfilter_euc_jp.h mbfilter_euc_jp_win.h mbfilter_euc_kr.h mbfilter_euc_tw.h mbfilter_htmlent.h mbfilter_hz.h mbfilter_iso2022_kr.h mbfilter_iso8859_1.h mbfilter_iso8859_10.h mbfilter_iso8859_13.h mbfilter_iso8859_14.h mbfilter_iso8859_15.h mbfilter_iso8859_16.h mbfilter_iso8859_2.h mbfilter_iso8859_3.h mbfilter_iso8859_4.h mbfilter_iso8859_5.h mbfilter_iso8859_6.h mbfilter_iso8859_7.h mbfilter_iso8859_8.h mbfilter_iso8859_9.h mbfilter_jis.h mbfilter_koi8r.h mbfilter_armscii8.h mbfilter_qprint.h mbfilter_sjis.h mbfilter_ucs2.h mbfilter_ucs4.h mbfilter_uhc.h mbfilter_utf16.h mbfilter_utf32.h mbfilter_utf7.h mbfilter_utf7imap.h mbfilter_utf8.h mbfilter_uuencode.h unicode_prop.h unicode_table_big5.h unicode_table_cns11643.h unicode_table_cp1251.h unicode_table_cp1252.h unicode_table_cp866.h unicode_table_cp932_ext.h unicode_table_cp936.h unicode_table_iso8859_10.h unicode_table_iso8859_13.h unicode_table_iso8859_14.h unicode_table_iso8859_15.h unicode_table_iso8859_16.h unicode_table_iso8859_2.h unicode_table_iso8859_3.h unicode_table_iso8859_4.h unicode_table_iso8859_5.h unicode_table_iso8859_6.h unicode_table_iso8859_7.h unicode_table_iso8859_8.h unicode_table_iso8859_9.h unicode_table_jis.h unicode_table_koi8r.h unicode_table_armscii8.h unicode_table_uhc.h
+libmbfl_filters_la_SOURCES=mbfilter_cp936.c mbfilter_hz.c mbfilter_euc_tw.c mbfilter_big5.c mbfilter_euc_jp.c mbfilter_jis.c mbfilter_iso8859_1.c mbfilter_iso8859_2.c mbfilter_cp1252.c mbfilter_cp1251.c mbfilter_ascii.c mbfilter_iso8859_3.c mbfilter_iso8859_4.c mbfilter_iso8859_5.c mbfilter_iso8859_6.c mbfilter_iso8859_7.c mbfilter_iso8859_8.c mbfilter_iso8859_9.c mbfilter_iso8859_10.c mbfilter_iso8859_13.c mbfilter_iso8859_14.c mbfilter_iso8859_15.c mbfilter_iso8859_16.c mbfilter_htmlent.c mbfilter_byte2.c mbfilter_byte4.c mbfilter_uuencode.c mbfilter_base64.c mbfilter_sjis.c mbfilter_7bit.c mbfilter_qprint.c mbfilter_ucs4.c mbfilter_ucs2.c mbfilter_utf32.c mbfilter_utf16.c mbfilter_utf8.c mbfilter_utf7.c mbfilter_utf7imap.c mbfilter_euc_jp_win.c mbfilter_cp932.c mbfilter_cp51932.c mbfilter_euc_cn.c mbfilter_euc_kr.c mbfilter_uhc.c mbfilter_iso2022_kr.c mbfilter_cp866.c mbfilter_koi8r.c mbfilter_armscii8.c html_entities.c cp932_table.h html_entities.h mbfilter_7bit.h mbfilter_ascii.h mbfilter_base64.h mbfilter_big5.h mbfilter_byte2.h mbfilter_byte4.h mbfilter_cp1251.h mbfilter_cp1252.h mbfilter_cp866.h mbfilter_cp932.h mbfilter_cp51932.h mbfilter_cp936.h mbfilter_euc_cn.h mbfilter_euc_jp.h mbfilter_euc_jp_win.h mbfilter_euc_kr.h mbfilter_euc_tw.h mbfilter_htmlent.h mbfilter_hz.h mbfilter_iso2022_kr.h mbfilter_iso8859_1.h mbfilter_iso8859_10.h mbfilter_iso8859_13.h mbfilter_iso8859_14.h mbfilter_iso8859_15.h mbfilter_iso8859_16.h mbfilter_iso8859_2.h mbfilter_iso8859_3.h mbfilter_iso8859_4.h mbfilter_iso8859_5.h mbfilter_iso8859_6.h mbfilter_iso8859_7.h mbfilter_iso8859_8.h mbfilter_iso8859_9.h mbfilter_jis.h mbfilter_koi8r.h mbfilter_armscii8.h mbfilter_qprint.h mbfilter_sjis.h mbfilter_ucs2.h mbfilter_ucs4.h mbfilter_uhc.h mbfilter_utf16.h mbfilter_utf32.h mbfilter_utf7.h mbfilter_utf7imap.h mbfilter_utf8.h mbfilter_uuencode.h unicode_prop.h unicode_table_big5.h unicode_table_cns11643.h unicode_table_cp1251.h unicode_table_cp1252.h unicode_table_cp866.h unicode_table_cp932_ext.h unicode_table_cp936.h unicode_table_iso8859_10.h unicode_table_iso8859_13.h unicode_table_iso8859_14.h unicode_table_iso8859_15.h unicode_table_iso8859_16.h unicode_table_iso8859_2.h unicode_table_iso8859_3.h unicode_table_iso8859_4.h unicode_table_iso8859_5.h unicode_table_iso8859_6.h unicode_table_iso8859_7.h unicode_table_iso8859_8.h unicode_table_iso8859_9.h unicode_table_jis.h unicode_table_koi8r.h unicode_table_armscii8.h unicode_table_uhc.h
mbfilter_iso8859_2.c: unicode_table_iso8859_2.h
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_euc_jp_win.c b/ext/mbstring/libmbfl/filters/mbfilter_euc_jp_win.c
index e57ae69356..bc07f13438 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_euc_jp_win.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_euc_jp_win.c
@@ -60,7 +60,8 @@ static const unsigned char mblen_table_eucjp[] = { /* 0xA1-0xFE */
};
-static const char *mbfl_encoding_eucjp_win_aliases[] = {"eucJP-open", NULL};
+static const char *mbfl_encoding_eucjp_win_aliases[] = {"eucJP-open",
+ "eucJP-ms", NULL};
const struct mbfl_identify_vtbl vtbl_identify_eucjpwin = {
mbfl_no_encoding_eucjp_win,
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_jis.c b/ext/mbstring/libmbfl/filters/mbfilter_jis.c
index 58336d4e28..3657658ba8 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_jis.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_jis.c
@@ -58,6 +58,15 @@ const mbfl_encoding mbfl_encoding_2022jp = {
MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE
};
+const mbfl_encoding mbfl_encoding_2022jpms = {
+ mbfl_no_encoding_2022jpms,
+ "ISO-2022-JP-MS",
+ "ISO-2022-JP-MS",
+ NULL,
+ NULL,
+ MBFL_ENCTYPE_MBCS | MBFL_ENCTYPE_SHFTCODE
+};
+
const struct mbfl_identify_vtbl vtbl_identify_jis = {
mbfl_no_encoding_jis,
mbfl_filt_ident_common_ctor,
@@ -72,6 +81,13 @@ const struct mbfl_identify_vtbl vtbl_identify_2022jp = {
mbfl_filt_ident_2022jp
};
+const struct mbfl_identify_vtbl vtbl_identify_2022jpms = {
+ mbfl_no_encoding_2022jpms,
+ mbfl_filt_ident_common_ctor,
+ mbfl_filt_ident_common_dtor,
+ mbfl_filt_ident_2022jp
+};
+
const struct mbfl_convert_vtbl vtbl_jis_wchar = {
mbfl_no_encoding_jis,
mbfl_no_encoding_wchar,
@@ -108,6 +124,24 @@ const struct mbfl_convert_vtbl vtbl_wchar_2022jp = {
mbfl_filt_conv_any_jis_flush
};
+const struct mbfl_convert_vtbl vtbl_2022jpms_wchar = {
+ mbfl_no_encoding_2022jpms,
+ mbfl_no_encoding_wchar,
+ mbfl_filt_conv_common_ctor,
+ mbfl_filt_conv_common_dtor,
+ mbfl_filt_conv_jis_wchar,
+ mbfl_filt_conv_common_flush
+};
+
+const struct mbfl_convert_vtbl vtbl_wchar_2022jpms = {
+ mbfl_no_encoding_wchar,
+ mbfl_no_encoding_2022jpms,
+ mbfl_filt_conv_common_ctor,
+ mbfl_filt_conv_common_dtor,
+ mbfl_filt_conv_wchar_jis,
+ mbfl_filt_conv_any_jis_flush
+};
+
#define CK(statement) do { if ((statement) < 0) return (-1); } while (0)
/*
@@ -130,12 +164,10 @@ retry:
filter->status += 2;
} else if (c == 0x0e) { /* "kana in" */
filter->status = 0x20;
+ CK((*filter->output_function)(c, filter->data));
} else if (c == 0x0f) { /* "kana out" */
filter->status = 0;
- } else if (filter->status == 0x10 && c == 0x5c) { /* YEN SIGN */
- CK((*filter->output_function)(0xa5, filter->data));
- } else if (filter->status == 0x10 && c == 0x7e) { /* OVER LINE */
- CK((*filter->output_function)(0x203e, filter->data));
+ CK((*filter->output_function)(c, filter->data));
} else if (filter->status == 0x20 && c > 0x20 && c < 0x60) { /* kana */
CK((*filter->output_function)(0xff40 + c, filter->data));
} else if ((filter->status == 0x80 || filter->status == 0x90) && c > 0x20 && c < 0x7f) { /* kanji first char */
@@ -161,9 +193,34 @@ retry:
s = (c1 - 0x21)*94 + c - 0x21;
if (filter->status == 0x80) {
if (s >= 0 && s < jisx0208_ucs_table_size) {
+ if ((filter->from)->no_encoding !=
+ mbfl_no_encoding_2022jpms) {
+ w = jisx0208_ucs_table[s];
+ }
+ else {
+ if ((c1 - 0x21) == 12) {
+ w = cp932ext1_ucs_table[s-12*94];
+ }
+ else {
+ if (c1 >= 0x79 && c1 <= 0x7c) {
+ w = cp932ext2_ucs_table[s-(0x79-0x21)*94];
+ }
+ else {
w = jisx0208_ucs_table[s];
+ }
+ }
+ }
} else {
+ if ((filter->from)->no_encoding !=
+ mbfl_no_encoding_2022jpms) {
+ w = 0;
+ } else {
+ if (c1 >= 0x79 && c1 <= 0x7c) {
+ w = cp932ext2_ucs_table[s-(0x79-0x21)*94];
+ } else {
w = 0;
+ }
+ }
}
if (w <= 0) {
w = (c1 << 8) | c;
@@ -287,7 +344,7 @@ retry:
int
mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter)
{
- int c1, s;
+ int c1, c2, s;
s = 0;
if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) {
@@ -299,6 +356,18 @@ mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter)
} else if (c >= ucs_r_jis_table_min && c < ucs_r_jis_table_max) {
s = ucs_r_jis_table[c - ucs_r_jis_table_min];
}
+ if (s > 0x8080 && s < 0x10000 &&
+ ((filter->to)->no_encoding == mbfl_no_encoding_2022jpms)) {
+ c1 = 0;
+ c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */
+ if (c == cp932ext2_ucs_table[c1]) {
+ s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ }
if (s <= 0) {
c1 = c & ~MBFL_WCSPLANE_MASK;
if (c1 == MBFL_WCSPLANE_JIS0208) {
@@ -327,8 +396,30 @@ mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter)
}
if (c == 0) {
s = 0;
- } else if (s <= 0) {
+ } else if (s <= 0 && ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms)) {
s = -1;
+ c1 = 0;
+ c2 = cp932ext1_ucs_table_max - cp932ext1_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext1 (13ku) */
+ if (c == cp932ext1_ucs_table[c1]) {
+ s = ((c1/94 + 0x2d) << 8) + (c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ if (s < 0 && ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms)) {
+ c1 = 0;
+ c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */
+ if (c == cp932ext2_ucs_table[c1]) {
+ s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ }
}
}
if (s >= 0) {
@@ -392,7 +483,7 @@ mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter)
int
mbfl_filt_conv_wchar_2022jp(int c, mbfl_convert_filter *filter)
{
- int s;
+ int c1, c2, s;
s = 0;
if (c >= ucs_a1_jis_table_min && c < ucs_a1_jis_table_max) {
@@ -428,9 +519,47 @@ mbfl_filt_conv_wchar_2022jp(int c, mbfl_convert_filter *filter)
s = 0;
} else if (s <= 0) {
s = -1;
+ if ( (filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms) {
+ c1 = 0;
+ c2 = cp932ext1_ucs_table_max - cp932ext1_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext1 (13ku) */
+ if (c == cp932ext1_ucs_table[c1]) {
+ s = ((c1/94 + 0x2d) << 8) + (c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ if ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms) {
+ c1 = 0;
+ c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */
+ if (c == cp932ext2_ucs_table[c1]) {
+ s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ }
+ }
}
- } else if ((s >= 0x80 && s < 0x2121) || (s > 0x8080)) {
+ } else if (((s >= 0x80 && s < 0x2121) &&
+ (filter->to)->no_encoding != mbfl_no_encoding_2022jpms) ||
+ (s > 0x8080)) {
s = -1;
+ if ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms) {
+ c1 = 0;
+ c2 = cp932ext2_ucs_table_max - cp932ext2_ucs_table_min;
+ while (c1 < c2) { /* CP932 vendor ext3 (115ku - 119ku) */
+ if (c == cp932ext2_ucs_table[c1]) {
+ s = ((c1/94 + 0x79) << 8) +(c1%94 + 0x21);
+ break;
+ }
+ c1++;
+ }
+ }
}
if (s >= 0) {
if (s < 0x80) { /* ASCII */
@@ -441,6 +570,15 @@ mbfl_filt_conv_wchar_2022jp(int c, mbfl_convert_filter *filter)
}
filter->status = 0;
CK((*filter->output_function)(s, filter->data));
+ } else if (s < 0x100 && ((filter->to)->no_encoding ==
+ mbfl_no_encoding_2022jpms)) { /* kana */
+ if ((filter->status & 0xff00) != 0x100) {
+ CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
+ CK((*filter->output_function)(0x28, filter->data)); /* '(' */
+ CK((*filter->output_function)(0x49, filter->data)); /* 'I' */
+ }
+ filter->status = 0x100;
+ CK((*filter->output_function)(s & 0x7f, filter->data));
} else if (s < 0x10000) { /* X 0208 */
if ((filter->status & 0xff00) != 0x200) {
CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_jis.h b/ext/mbstring/libmbfl/filters/mbfilter_jis.h
index 0375307263..1ba244a282 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_jis.h
+++ b/ext/mbstring/libmbfl/filters/mbfilter_jis.h
@@ -34,12 +34,16 @@
extern const mbfl_encoding mbfl_encoding_jis;
extern const mbfl_encoding mbfl_encoding_2022jp;
+extern const mbfl_encoding mbfl_encoding_2022jpms;
extern const struct mbfl_identify_vtbl vtbl_identify_2022jp;
+extern const struct mbfl_identify_vtbl vtbl_identify_2022jpms;
extern const struct mbfl_identify_vtbl vtbl_identify_jis;
extern const struct mbfl_convert_vtbl vtbl_jis_wchar;
extern const struct mbfl_convert_vtbl vtbl_wchar_jis;
extern const struct mbfl_convert_vtbl vtbl_2022jp_wchar;
extern const struct mbfl_convert_vtbl vtbl_wchar_2022jp;
+extern const struct mbfl_convert_vtbl vtbl_2022jpms_wchar;
+extern const struct mbfl_convert_vtbl vtbl_wchar_2022jpms;
int mbfl_filt_conv_jis_wchar(int c, mbfl_convert_filter *filter);
int mbfl_filt_conv_wchar_jis(int c, mbfl_convert_filter *filter);
diff --git a/ext/mbstring/libmbfl/filters/unicode_table_jis.h b/ext/mbstring/libmbfl/filters/unicode_table_jis.h
index 5671c4e851..e87dad93c8 100644
--- a/ext/mbstring/libmbfl/filters/unicode_table_jis.h
+++ b/ext/mbstring/libmbfl/filters/unicode_table_jis.h
@@ -36,13 +36,13 @@ static const unsigned short jisx0208_ucs_table[] = {
0xFF1F,0xFF01,0x309B,0x309C,0x00B4,0xFF40,0x00A8,0xFF3E,
0xFFE3,0xFF3F,0x30FD,0x30FE,0x309D,0x309E,0x3003,0x4EDD,
0x3005,0x3006,0x3007,0x30FC,0x2015,0x2010,0xFF0F,0xFF3C,
- 0x301C,0x2016,0xFF5C,0x2026,0x2025,0x2018,0x2019,0x201C,
+ 0xFF5E,0x2225,0xFF5C,0x2026,0x2025,0x2018,0x2019,0x201C,
0x201D,0xFF08,0xFF09,0x3014,0x3015,0xFF3B,0xFF3D,0xFF5B,
0xFF5D,0x3008,0x3009,0x300A,0x300B,0x300C,0x300D,0x300E,
- 0x300F,0x3010,0x3011,0xFF0B,0x2212,0x00B1,0x00D7,0x00F7,
+ 0x300F,0x3010,0x3011,0xFF0B,0xFF0D,0x00B1,0x00D7,0x00F7,
0xFF1D,0x2260,0xFF1C,0xFF1E,0x2266,0x2267,0x221E,0x2234,
0x2642,0x2640,0x00B0,0x2032,0x2033,0x2103,0xFFE5,0xFF04,
- 0x00A2,0x00A3,0xFF05,0xFF03,0xFF06,0xFF0A,0xFF20,0x00A7,
+ 0xFFE0,0xFFE1,0xFF05,0xFF03,0xFF06,0xFF0A,0xFF20,0x00A7,
0x2606,0x2605,0x25CB,0x25CF,0x25CE,0x25C7,
/* ku 2 */
@@ -51,7 +51,7 @@ static const unsigned short jisx0208_ucs_table[] = {
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x2208,0x220B,0x2286,0x2287,0x2282,0x2283,0x222A,
0x2229,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x2227,0x2228,0x00AC,0x21D2,0x21D4,0x2200,0x2203,
+ 0x0000,0x2227,0x2228,0xFFE2,0x21D2,0x21D4,0x2200,0x2203,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x2220,0x22A5,0x2312,0x2202,0x2207,
0x2261,0x2252,0x226A,0x226B,0x221A,0x223D,0x221D,0x2235,
@@ -1217,9 +1217,9 @@ static const unsigned short jisx0212_ucs_table[] = {
/* ku 2 */
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x02D8,0x02C7,
- 0x00B8,0x02D9,0x02DD,0x00AF,0x02DB,0x02DA,0x007E,0x0384,
+ 0x00B8,0x02D9,0x02DD,0x00AF,0x02DB,0x02DA,0xFF5E,0x0384,
0x0385,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x00A1,0x00A6,0x00BF,0x0000,0x0000,0x0000,0x0000,
+ 0x0000,0x00A1,0xFFE4,0x00BF,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
@@ -2471,7 +2471,7 @@ static const unsigned short ucs_a2_jis_table[] = {
/* 2100h */
0x0000,0x0000,0x0000,0x216E,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xA2F1,0x0000,
+ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x2d62,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0xA2EF,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x2272,0x0000,0x0000,0x0000,0x0000,
diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter.c b/ext/mbstring/libmbfl/mbfl/mbfilter.c
index ed674b2b65..a8e3b68d33 100644
--- a/ext/mbstring/libmbfl/mbfl/mbfilter.c
+++ b/ext/mbstring/libmbfl/mbfl/mbfilter.c
@@ -470,7 +470,6 @@ enum mbfl_no_encoding mbfl_encoding_detector_judge(mbfl_encoding_detector *ident
n--;
}
- /* fallback judge */
if (encoding == mbfl_no_encoding_invalid) {
n = identd->filter_list_size - 1;
while (n >= 0) {
@@ -631,7 +630,6 @@ mbfl_identify_encoding(mbfl_string *string, enum mbfl_no_encoding *elist, int el
}
}
-
/* cleanup */
/* dtors should be called in reverse order */
i = num; while (--i >= 0) {
diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_convert.c b/ext/mbstring/libmbfl/mbfl/mbfl_convert.c
index 78a995cd25..bcae8c4340 100644
--- a/ext/mbstring/libmbfl/mbfl/mbfl_convert.c
+++ b/ext/mbstring/libmbfl/mbfl/mbfl_convert.c
@@ -51,6 +51,7 @@
#include "filters/mbfilter_euc_kr.h"
#include "filters/mbfilter_iso2022_kr.h"
#include "filters/mbfilter_sjis.h"
+#include "filters/mbfilter_cp51932.h"
#include "filters/mbfilter_jis.h"
#include "filters/mbfilter_euc_jp.h"
#include "filters/mbfilter_euc_jp_win.h"
@@ -104,10 +105,14 @@ const struct mbfl_convert_vtbl *mbfl_convert_filter_list[] = {
&vtbl_wchar_eucjp,
&vtbl_sjis_wchar,
&vtbl_wchar_sjis,
+ &vtbl_cp51932_wchar,
+ &vtbl_wchar_cp51932,
&vtbl_jis_wchar,
&vtbl_wchar_jis,
&vtbl_2022jp_wchar,
&vtbl_wchar_2022jp,
+ &vtbl_2022jpms_wchar,
+ &vtbl_wchar_2022jpms,
&vtbl_eucjpwin_wchar,
&vtbl_wchar_eucjpwin,
&vtbl_sjiswin_wchar,
diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_encoding.c b/ext/mbstring/libmbfl/mbfl/mbfl_encoding.c
index 64d8cb4e47..3c18fca974 100644
--- a/ext/mbstring/libmbfl/mbfl/mbfl_encoding.c
+++ b/ext/mbstring/libmbfl/mbfl/mbfl_encoding.c
@@ -57,6 +57,7 @@
#include "filters/mbfilter_euc_kr.h"
#include "filters/mbfilter_iso2022_kr.h"
#include "filters/mbfilter_sjis.h"
+#include "filters/mbfilter_cp51932.h"
#include "filters/mbfilter_jis.h"
#include "filters/mbfilter_euc_jp.h"
#include "filters/mbfilter_euc_jp_win.h"
@@ -149,8 +150,10 @@ static const mbfl_encoding *mbfl_encoding_ptr_list[] = {
&mbfl_encoding_sjis,
&mbfl_encoding_eucjp_win,
&mbfl_encoding_sjis_win,
+ &mbfl_encoding_cp51932,
&mbfl_encoding_jis,
&mbfl_encoding_2022jp,
+ &mbfl_encoding_2022jpms,
&mbfl_encoding_cp1252,
&mbfl_encoding_8859_1,
&mbfl_encoding_8859_2,
diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_encoding.h b/ext/mbstring/libmbfl/mbfl/mbfl_encoding.h
index d38b1d7d4a..af93b6ea50 100644
--- a/ext/mbstring/libmbfl/mbfl/mbfl_encoding.h
+++ b/ext/mbstring/libmbfl/mbfl/mbfl_encoding.h
@@ -70,8 +70,10 @@ enum mbfl_no_encoding {
mbfl_no_encoding_eucjp_win,
mbfl_no_encoding_sjis_win,
mbfl_no_encoding_sjis_mac,
+ mbfl_no_encoding_cp51932,
mbfl_no_encoding_jis,
mbfl_no_encoding_2022jp,
+ mbfl_no_encoding_2022jpms,
mbfl_no_encoding_cp1252,
mbfl_no_encoding_8859_1,
mbfl_no_encoding_8859_2,
diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_ident.c b/ext/mbstring/libmbfl/mbfl/mbfl_ident.c
index 72ccef68d2..40c964c205 100644
--- a/ext/mbstring/libmbfl/mbfl/mbfl_ident.c
+++ b/ext/mbstring/libmbfl/mbfl/mbfl_ident.c
@@ -106,6 +106,7 @@ static const struct mbfl_identify_vtbl *mbfl_identify_filter_list[] = {
&vtbl_identify_sjiswin,
&vtbl_identify_jis,
&vtbl_identify_2022jp,
+ &vtbl_identify_2022jpms,
&vtbl_identify_euccn,
&vtbl_identify_cp936,
&vtbl_identify_hz,
diff --git a/ext/mbstring/mb_gpc.c b/ext/mbstring/mb_gpc.c
index d5adaddd0e..46b1f41283 100644
--- a/ext/mbstring/mb_gpc.c
+++ b/ext/mbstring/mb_gpc.c
@@ -153,6 +153,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;
@@ -331,6 +333,7 @@ enum mbfl_no_encoding _php_mb_encoding_handler_ex(const php_mb_encoding_handler_
out:
if (convd != NULL) {
+ MBSTRG(illegalchars) += mbfl_buffer_illegalchars(convd);
mbfl_buffer_converter_delete(convd);
}
if (val_list != NULL) {
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 41a30e9990..fd6143acc7 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -60,6 +60,7 @@
#include "ext/standard/url.h"
#include "main/php_output.h"
#include "ext/standard/info.h"
+
#include "libmbfl/mbfl/mbfl_allocators.h"
#include "php_variables.h"
@@ -936,7 +937,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)) {
@@ -967,14 +971,14 @@ PHP_RINIT_FUNCTION(mbstring)
zend_hash_find(EG(function_table), p->ovld_func, strlen(p->ovld_func)+1 , (void **)&func);
if (zend_hash_find(EG(function_table), p->orig_func, strlen(p->orig_func)+1, (void **)&orig) != SUCCESS) {
- php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't find function %s", p->orig_func);
+ php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't find function %s.", p->orig_func);
return FAILURE;
} else {
zend_hash_add(EG(function_table), p->save_func, strlen(p->save_func)+1, orig, sizeof(zend_function), NULL);
if (zend_hash_update(EG(function_table), p->orig_func, strlen(p->orig_func)+1, func, sizeof(zend_function),
NULL) == FAILURE) {
- php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't replace function %s", p->orig_func);
+ php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring couldn't replace function %s.", p->orig_func);
return FAILURE;
}
}
@@ -1341,7 +1345,7 @@ PHP_FUNCTION(mb_substitute_character)
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_substchar) = Z_LVAL_PP(arg1);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown character");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown character.");
RETVAL_FALSE;
}
}
@@ -1352,7 +1356,7 @@ PHP_FUNCTION(mb_substitute_character)
MBSTRG(current_filter_illegal_mode) = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
MBSTRG(current_filter_illegal_substchar) = Z_LVAL_PP(arg1);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown character");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown character.");
RETVAL_FALSE;
}
break;
@@ -1599,11 +1603,11 @@ PHP_FUNCTION(mb_strpos)
}
if (offset < 0 || (unsigned long)offset > haystack.len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is out of range");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string.");
RETURN_FALSE;
}
if (needle.len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty needle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty delimiter.");
RETURN_FALSE;
}
@@ -1615,16 +1619,16 @@ PHP_FUNCTION(mb_strpos)
case 1:
break;
case 2:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Needle has non-positive length");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Needle has not positive length.");
break;
case 4:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding or conversion error");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding or conversion error.");
break;
case 8:
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Argument is empty");
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Argument is empty.");
break;
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error in mb_strpos");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown error in mb_strpos.");
break;
}
RETVAL_FALSE;
@@ -1637,10 +1641,13 @@ PHP_FUNCTION(mb_strpos)
PHP_FUNCTION(mb_strrpos)
{
int n;
- long offset = 0;
mbfl_string haystack, needle;
char *enc_name = NULL;
int enc_name_len;
+ zval **zoffset;
+ long offset = 0, str_flg;
+ char *enc_name2 = NULL;
+ int enc_name_len2;
mbfl_string_init(&haystack);
mbfl_string_init(&needle);
@@ -1649,10 +1656,51 @@ PHP_FUNCTION(mb_strrpos)
needle.no_language = MBSTRG(current_language);
needle.no_encoding = MBSTRG(current_internal_encoding);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ls", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &offset, &enc_name, &enc_name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|Zs", (char **)&haystack.val, &haystack.len, (char **)&needle.val, &needle.len, &zoffset, &enc_name, &enc_name_len) == FAILURE) {
RETURN_FALSE;
}
+ if(ZEND_NUM_ARGS() >= 3) {
+ if (Z_TYPE_PP(zoffset) == IS_STRING) {
+ enc_name2 = Z_STRVAL_PP(zoffset);
+ enc_name_len2 = Z_STRLEN_PP(zoffset);
+ str_flg = 1;
+
+ if (enc_name2 != NULL) {
+ switch (*enc_name2) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case ' ':
+ case '-':
+ case '.':
+ break;
+ default :
+ str_flg = 0;
+ break;
+ }
+ }
+
+ if(str_flg) {
+ convert_to_long_ex(zoffset);
+ offset = Z_LVAL_PP(zoffset);
+ } else {
+ enc_name = enc_name2;
+ enc_name_len = enc_name_len2;
+ }
+ } else {
+ convert_to_long_ex(zoffset);
+ offset = Z_LVAL_PP(zoffset);
+ }
+ }
+
if (enc_name != NULL) {
haystack.no_encoding = needle.no_encoding = mbfl_name2no_encoding(enc_name);
if (haystack.no_encoding == mbfl_no_encoding_invalid) {
@@ -1662,11 +1710,9 @@ PHP_FUNCTION(mb_strrpos)
}
if (haystack.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty haystack");
RETURN_FALSE;
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
RETURN_FALSE;
}
n = mbfl_strpos(&haystack, &needle, offset, 1);
@@ -1720,6 +1766,10 @@ PHP_FUNCTION(mb_strripos)
RETURN_FALSE;
}
+ if(offset > old_haystack_len){
+ RETURN_FALSE;
+ }
+
n = php_mb_stripos(1, old_haystack, old_haystack_len, old_needle, old_needle_len, offset, from_encoding TSRMLS_CC);
if (n >= 0) {
@@ -1759,12 +1809,8 @@ PHP_FUNCTION(mb_strstr)
}
}
- if (haystack.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty haystack");
- RETURN_FALSE;
- }
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty delimiter.");
RETURN_FALSE;
}
n = mbfl_strpos(&haystack, &needle, 0, 0);
@@ -1821,8 +1867,10 @@ PHP_FUNCTION(mb_strrchr)
}
}
+ if (haystack.len <= 0) {
+ RETURN_FALSE;
+ }
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
RETURN_FALSE;
}
n = mbfl_strpos(&haystack, &needle, 0, 1);
@@ -1870,6 +1918,11 @@ PHP_FUNCTION(mb_stristr)
RETURN_FALSE;
}
+ if(!needle.len){
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty delimiter.");
+ RETURN_FALSE;
+ }
+
haystack.no_encoding = needle.no_encoding = mbfl_name2no_encoding(from_encoding);
if (haystack.no_encoding == mbfl_no_encoding_invalid) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown encoding \"%s\"", from_encoding);
@@ -1983,7 +2036,7 @@ PHP_FUNCTION(mb_substr_count)
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty needle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Empty substring.");
RETURN_FALSE;
}
@@ -2166,7 +2219,7 @@ PHP_FUNCTION(mb_strcut)
if (((unsigned) from + (unsigned) len) > Z_STRLEN_PP(arg1)) {
len = Z_STRLEN_PP(arg1) - from;
}
-
+
ret = mbfl_strcut(&string, &result, from, len);
if (ret != NULL) {
RETVAL_STRINGL(ret->val, ret->len, 0); /* the string is already strdup()'ed */
@@ -2526,7 +2579,7 @@ PHP_FUNCTION(mb_detect_encoding)
mbfl_string string;
const char *ret;
enum mbfl_no_encoding *elist;
- int size, *list, strict;
+ int size, *list, strict = 0;
if (ZEND_NUM_ARGS() == 1) {
if (zend_get_parameters_ex(1, &arg_str) == FAILURE) {
@@ -3904,8 +3957,8 @@ PHP_FUNCTION(mb_get_info)
if (lang != NULL && (name = (char *)mbfl_no_encoding2name(lang->mail_body_encoding)) != NULL) {
RETVAL_STRING(name, 1);
}
- } else if (!strcasecmp("illegal_chars", typ)) {
- RETVAL_LONG(MBSTRG(illegalchars));
+ } else if (!strcasecmp("illegal_chars", typ)) {
+ RETVAL_LONG(MBSTRG(illegalchars));
} else if (!strcasecmp("encoding_translation", typ)) {
if (MBSTRG(encoding_translation)) {
RETVAL_STRING("On", 1);
@@ -4019,8 +4072,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;
}
@@ -4297,7 +4355,6 @@ MBSTRING_API int php_mb_stripos(int mode, char *old_haystack, int old_haystack_l
}
if (haystack.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty haystack");
break;
}
@@ -4308,7 +4365,6 @@ MBSTRING_API int php_mb_stripos(int mode, char *old_haystack, int old_haystack_l
}
if (needle.len <= 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty needle");
break;
}
@@ -4319,7 +4375,7 @@ MBSTRING_API int php_mb_stripos(int mode, char *old_haystack, int old_haystack_l
}
if (offset < 0 || (unsigned long)offset > haystack.len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is out of range");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset not contained in string.");
break;
}