Skip to content

Commit c33589e

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix mb_strlen is wrong length for CP932 when 0x80.
2 parents 0e7ad40 + c50172e commit c33589e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ext/mbstring/libmbfl/filters/mbfilter_cp932.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static size_t mb_cp932_to_wchar(unsigned char **in, size_t *in_len, uint32_t *bu
6868
static void mb_wchar_to_cp932(uint32_t *in, size_t len, mb_convert_buf *buf, bool end);
6969
static void mb_wchar_to_sjiswin(uint32_t *in, size_t len, mb_convert_buf *buf, bool end);
7070

71-
static const unsigned char mblen_table_sjis[] = { /* 0x80-0x9f,0xE0-0xFF */
71+
static const unsigned char mblen_table_sjis[] = { /* 0x81-0x9f,0xE0-0xFF */
7272
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7373
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7474
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -77,7 +77,7 @@ static const unsigned char mblen_table_sjis[] = { /* 0x80-0x9f,0xE0-0xFF */
7777
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7878
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
7979
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
80-
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
80+
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
8181
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
8282
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
8383
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,

ext/mbstring/tests/mb_strlen.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ print "-- Testing illegal bytes 0x80,0xFD-FF --\n";
3535
print mb_strlen("\x80\xA1", 'SJIS') . "\n";
3636
print mb_strlen("abc\xFD\xFE\xFF", 'SJIS') . "\n";
3737

38+
echo "== CP932 ==\n";
39+
print mb_strlen("\x80\xA1", "CP932") . "\n";
40+
// 0xFD, 0xFE, 0xFF is reserved.
41+
print mb_strlen("abc\xFD\xFE\xFF", 'CP932') . "\n";
42+
3843
echo "== MacJapanese ==\n";
3944
print mb_strlen("\x80\xA1", 'MacJapanese') . "\n";
4045
print mb_strlen("abc\xFD\xFE\xFF", 'MacJapanese') . "\n";
@@ -91,6 +96,9 @@ try {
9196
-- Testing illegal bytes 0x80,0xFD-FF --
9297
2
9398
6
99+
== CP932 ==
100+
2
101+
5
94102
== MacJapanese ==
95103
2
96104
6

0 commit comments

Comments
 (0)