[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Sun, 23 Oct 2011 11:54:06 + Revision: http://svn.php.net/viewvc?view=revisionrevision=318340 Log: removed invalid two byte sequenct for utf-8. Changed paths: U php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-10-23 11:09:40 UTC (rev 318339) +++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-10-23 11:54:06 UTC (rev 318340) @@ -49,8 +49,8 @@ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Tue, 18 Oct 2011 14:03:44 + Revision: http://svn.php.net/viewvc?view=revisionrevision=318183 Log: fixed byte length of utf-8. Changed paths: U php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-10-18 11:38:47 UTC (rev 318182) +++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-10-18 14:03:44 UTC (rev 318183) @@ -52,7 +52,7 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1 + 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; static const char *mbfl_encoding_utf8_aliases[] = {utf8, NULL}; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Wed, 07 Sep 2011 14:30:06 + Revision: http://svn.php.net/viewvc?view=revisionrevision=316357 Log: fixed invalid utf-8 check. Changed paths: U php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-09-07 14:25:12 UTC (rev 316356) +++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-09-07 14:30:06 UTC (rev 316357) @@ -101,10 +101,15 @@ int s, c1, w = 0, flag = 0; if (c 0x80) { + if (filter-status != 0) { + w = (filter-cache MBFL_WCSGROUP_MASK) | MBFL_WCSGROUP_THROUGH; + CK((*filter-output_function)(w, filter-data)); + filter-status = 0; + filter-cache = 0; + } if (c = 0) { CK((*filter-output_function)(c, filter-data)); } - filter-status = 0; } else if (c 0xc0) { int status = filter-status 0xff; switch (status) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c mbfilter_utf8_mobile.c
hirokawa Sat, 27 Aug 2011 01:25:10 + Revision: http://svn.php.net/viewvc?view=revisionrevision=315598 Log: corrected valid unicode area. Changed paths: U php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c U php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-27 01:23:12 UTC (rev 315597) +++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-27 01:25:10 UTC (rev 315598) @@ -116,7 +116,7 @@ filter-cache = 0; if ((status == 0x10 s = 0x80) || (status == 0x21 s = 0x800 (s 0xd800 || s 0xdfff)) || - (status == 0x32 s = 0x1 s 0x20)) { + (status == 0x32 s = 0x1 s 0x11)) { CK((*filter-output_function)(s, filter-data)); } else { w = s MBFL_WCSGROUP_MASK; Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c === --- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c 2011-08-27 01:23:12 UTC (rev 315597) +++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c 2011-08-27 01:25:10 UTC (rev 315598) @@ -207,7 +207,7 @@ filter-cache = 0; if ((status == 0x10 s = 0x80) || (status == 0x21 s = 0x800 (s 0xd800 || s 0xdfff)) || - (status == 0x32 s = 0x1 s 0x20)) { + (status == 0x32 s = 0x1 s 0x11)) { if (filter-from-no_encoding == mbfl_no_encoding_utf8_docomo mbfilter_conv_r_map_tbl(s, s1, mbfl_docomo2uni_pua, 4) 0) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Sat, 06 Aug 2011 02:22:15 + Revision: http://svn.php.net/viewvc?view=revisionrevision=314357 Log: added ill-formed utf-8 check for 0xED. Changed paths: U php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-06 01:53:34 UTC (rev 314356) +++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-06 02:22:15 UTC (rev 314357) @@ -124,10 +124,12 @@ CK((*filter-output_function)(w, filter-data)); } break; - case 0x20: /* 3byte code 2nd char: 0:0xa0-0xbf,1-F:0x80-0x9f */ + case 0x20: /* 3byte code 2nd char: 0:0xa0-0xbf,D:0x80-9F,1-C,E-F:0x80-0x9f */ s = filter-cache | ((c 0x3f) 6); c1 = (s 12) 0xf; - if ((c1 == 0x0 c = 0xa0) || c1 0) { + if ((c1 == 0x0 c = 0xa0) || + (c1 == 0xd c 0xa0) || + (c1 0x0 c1 != 0xd)) { filter-cache = s; filter-status++; } else { @@ -235,7 +237,9 @@ } else if (c 0xc0) { switch (filter-status) { case 0x20: /* 3 byte code 2nd char */ - if ((c1 == 0x0 c = 0xa0) || c1 0x0) { + if ((c1 == 0x0 c = 0xa0) || + (c1 == 0xd c 0xa0) || + (c1 0x0 c1 != 0xd)) { filter-status++; } else { filter-flag = 1; /* bad */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Sat, 06 Aug 2011 04:25:44 + Revision: http://svn.php.net/viewvc?view=revisionrevision=314359 Log: improved error handling for ill-formed utf-8 based on the Unicode recommendation. Changed paths: U php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-06 02:22:38 UTC (rev 314358) +++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-06 04:25:44 UTC (rev 314359) @@ -98,7 +98,7 @@ */ int mbfl_filt_conv_utf8_wchar(int c, mbfl_convert_filter *filter) { - int s, c1, w = 0; + int s, c1, w = 0, flag = 0; if (c 0x80) { if (c = 0) { @@ -120,8 +120,7 @@ CK((*filter-output_function)(s, filter-data)); } else { w = s MBFL_WCSGROUP_MASK; - w |= MBFL_WCSGROUP_THROUGH; - CK((*filter-output_function)(w, filter-data)); + flag = 1; } break; case 0x20: /* 3byte code 2nd char: 0:0xa0-0xbf,D:0x80-9F,1-C,E-F:0x80-0x9f */ @@ -134,10 +133,7 @@ filter-status++; } else { w = s MBFL_WCSGROUP_MASK; - w |= MBFL_WCSGROUP_THROUGH; - CK((*filter-output_function)(w, filter-data)); - filter-status = 0; - filter-cache = 0; + flag = 1; } break; case 0x31: /* 4byte code 3rd char: 0x80-0xbf */ @@ -154,33 +150,47 @@ filter-status++; } else { w = s MBFL_WCSGROUP_MASK; - w |= MBFL_WCSGROUP_THROUGH; - CK((*filter-output_function)(w, filter-data)); - filter-status = 0; - filter-cache = 0; + flag = 1; } break; default: - filter-status = 0; + w = c MBFL_WCSGROUP_MASK; + flag = 1; break; } } else if (c 0xc2) { /* invalid: 0xc0,0xc1 */ w = c MBFL_WCSGROUP_MASK; - w |= MBFL_WCSGROUP_THROUGH; - CK((*filter-output_function)(w, filter-data)); - filter-status = 0; - filter-cache = 0; + flag = 1; } else if (c 0xe0) { /* 2byte code first char: 0xc2-0xdf */ - filter-status = 0x10; - filter-cache = (c 0x1f) 6; + if (filter-status == 0x0) { + filter-status = 0x10; + filter-cache = (c 0x1f) 6; + } else { + w = c MBFL_WCSGROUP_MASK; + flag = 1; + } } else if (c 0xf0) { /* 3byte code first char: 0xe0-0xef */ - filter-status = 0x20; - filter-cache = (c 0xf) 12; + if (filter-status == 0x0) { + filter-status = 0x20; + filter-cache = (c 0xf) 12; + } else { + w = c MBFL_WCSGROUP_MASK; + flag = 1; + } } else if (c 0xf5) { /* 4byte code first char: 0xf0-0xf4 */ - filter-status = 0x30; - filter-cache = (c 0x7) 18; + if (filter-status == 0x0) { + filter-status = 0x30; + filter-cache = (c 0x7) 18; + } else { + w = c MBFL_WCSGROUP_MASK; + flag = 1; + } } else { w = c MBFL_WCSGROUP_MASK; + flag = 1; + } + + if (flag) { w |= MBFL_WCSGROUP_THROUGH; CK((*filter-output_function)(w, filter-data)); filter-status = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Thu, 04 Aug 2011 12:11:04 + Revision: http://svn.php.net/viewvc?view=revisionrevision=314254 Log: removed invalid 5,6 byte encoding from utf-8 based on Unicode 5.2. Changed paths: U php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-04 12:05:48 UTC (rev 314253) +++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-04 12:11:04 UTC (rev 314254) @@ -52,7 +52,7 @@ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1 + 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1 }; static const char *mbfl_encoding_utf8_aliases[] = {utf8, NULL}; @@ -111,40 +111,23 @@ case 0x10: /* 2byte code 2nd char */ case 0x21: /* 3byte code 3rd char */ case 0x32: /* 4byte code 4th char */ - case 0x43: /* 5byte code 5th char */ - case 0x54: /* 6byte code 6th char */ filter-status = 0; s = filter-cache | (c 0x3f); if ((status == 0x10 s = 0x80) || (status == 0x21 s = 0x800 (s 0xd800 || s 0xdfff)) || - (status == 0x32 s = 0x1) || - (status == 0x43 s = 0x20) || - (status == 0x54 s = 0x400 s MBFL_WCSGROUP_UCS4MAX)) { + (status == 0x32 s = 0x1 s 0x20)) { CK((*filter-output_function)(s, filter-data)); } break; case 0x20: /* 3byte code 2nd char */ case 0x31: /* 4byte code 3rd char */ - case 0x42: /* 5byte code 4th char */ - case 0x53: /* 6byte code 5th char */ filter-cache |= ((c 0x3f) 6); filter-status++; break; case 0x30: /* 4byte code 2nd char */ - case 0x41: /* 5byte code 3rd char */ - case 0x52: /* 6byte code 4th char */ filter-cache |= ((c 0x3f) 12); filter-status++; break; - case 0x40: /* 5byte code 2nd char */ - case 0x51: /* 6byte code 3rd char */ - filter-cache |= ((c 0x3f) 18); - filter-status++; - break; - case 0x50: /* 6byte code 2nd char */ - filter-cache |= ((c 0x3f) 24); - filter-status++; - break; default: filter-status = 0; break; @@ -158,12 +141,6 @@ } else if (c 0xf8) { /* 4byte code first char */ filter-status = 0x30; filter-cache = (c 0x7) 18; - } else if (c 0xfc) { /* 5byte code first char */ - filter-status = 0x40; - filter-cache = (c 0x3) 24; - } else if (c 0xfe) { /* 6 byte code first char */ - filter-status = 0x50; - filter-cache = (c 0x1) 30; } else { filter-status = 0; filter-cache = 0; @@ -177,7 +154,7 @@ */ int mbfl_filt_conv_wchar_utf8(int c, mbfl_convert_filter *filter) { - if (c = 0 c MBFL_WCSGROUP_UCS4MAX) { + if (c = 0 c 0x20) { if (c 0x80) { CK((*filter-output_function)(c, filter-data)); } else if (c 0x800) { @@ -187,24 +164,11 @@ CK((*filter-output_function)(((c 12) 0x0f) | 0xe0, filter-data)); CK((*filter-output_function)(((c 6) 0x3f) | 0x80, filter-data)); CK((*filter-output_function)((c 0x3f) | 0x80, filter-data)); - } else if (c 0x20) { + } else { CK((*filter-output_function)(((c 18) 0x07) | 0xf0, filter-data)); CK((*filter-output_function)(((c 12) 0x3f) | 0x80, filter-data)); CK((*filter-output_function)(((c 6) 0x3f) | 0x80, filter-data)); CK((*filter-output_function)((c 0x3f) | 0x80, filter-data)); - } else if (c 0x400) { - CK((*filter-output_function)(((c 24) 0x03) | 0xf8, filter-data)); - CK((*filter-output_function)(((c 18) 0x3f) | 0x80, filter-data)); - CK((*filter-output_function)(((c 12) 0x3f) | 0x80, filter-data)); -
[PHP-CVS] svn: /php/php-src/trunk/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Fri, 05 Aug 2011 04:28:24 + Revision: http://svn.php.net/viewvc?view=revisionrevision=314302 Log: added check for invalid utf-8 encoding (merge from libmbfl-1.3.1). Changed paths: U php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-05 03:41:24 UTC (rev 314301) +++ php/php-src/trunk/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-05 04:28:24 UTC (rev 314302) @@ -98,7 +98,7 @@ */ int mbfl_filt_conv_utf8_wchar(int c, mbfl_convert_filter *filter) { - int s; + int s, c1, w = 0; if (c 0x80) { if (c = 0) { @@ -108,40 +108,79 @@ } else if (c 0xc0) { int status = filter-status 0xff; switch (status) { - case 0x10: /* 2byte code 2nd char */ - case 0x21: /* 3byte code 3rd char */ - case 0x32: /* 4byte code 4th char */ + case 0x10: /* 2byte code 2nd char: 0x80-0xbf */ + case 0x21: /* 3byte code 3rd char: 0x80-0xbf */ + case 0x32: /* 4byte code 4th char: 0x80-0xbf */ filter-status = 0; s = filter-cache | (c 0x3f); + filter-cache = 0; if ((status == 0x10 s = 0x80) || (status == 0x21 s = 0x800 (s 0xd800 || s 0xdfff)) || (status == 0x32 s = 0x1 s 0x20)) { CK((*filter-output_function)(s, filter-data)); + } else { + w = s MBFL_WCSGROUP_MASK; + w |= MBFL_WCSGROUP_THROUGH; + CK((*filter-output_function)(w, filter-data)); } break; - case 0x20: /* 3byte code 2nd char */ - case 0x31: /* 4byte code 3rd char */ + case 0x20: /* 3byte code 2nd char: 0:0xa0-0xbf,1-F:0x80-0x9f */ + s = filter-cache | ((c 0x3f) 6); + c1 = (s 12) 0xf; + if ((c1 == 0x0 c = 0xa0) || c1 0) { + filter-cache = s; + filter-status++; + } else { + w = s MBFL_WCSGROUP_MASK; + w |= MBFL_WCSGROUP_THROUGH; + CK((*filter-output_function)(w, filter-data)); + filter-status = 0; + filter-cache = 0; + } + break; + case 0x31: /* 4byte code 3rd char: 0x80-0xbf */ filter-cache |= ((c 0x3f) 6); filter-status++; break; - case 0x30: /* 4byte code 2nd char */ - filter-cache |= ((c 0x3f) 12); - filter-status++; + case 0x30: /* 4byte code 2nd char: 0:0x90-0xbf,1-3:0x80-0xbf,4:0x80-0x8f */ + s = filter-cache | ((c 0x3f) 12); + c1 = (s 18) 0x7; + if ((c1 == 0x0 c = 0x90) || + (c1 0x0 c1 0x4) || + (c1 == 0x4 c 0x90)) { + filter-cache = s; + filter-status++; + } else { + w = s MBFL_WCSGROUP_MASK; + w |= MBFL_WCSGROUP_THROUGH; + CK((*filter-output_function)(w, filter-data)); + filter-status = 0; + filter-cache = 0; + } break; default: filter-status = 0; break; } - } else if (c 0xe0) { /* 2byte code first char */ + } else if (c 0xc2) { /* invalid: 0xc0,0xc1 */ + w = c MBFL_WCSGROUP_MASK; + w |= MBFL_WCSGROUP_THROUGH; + CK((*filter-output_function)(w, filter-data)); + filter-status = 0; + filter-cache = 0; + } else if (c 0xe0) { /* 2byte code first char: 0xc2-0xdf */ filter-status = 0x10; filter-cache = (c 0x1f) 6; - } else if (c 0xf0) { /* 3byte code first char */ + } else if (c 0xf0) { /* 3byte code first char: 0xe0-0xef */ filter-status = 0x20; filter-cache = (c 0xf) 12; - } else if (c 0xf8) { /* 4byte code first char */ + } else if (c 0xf5) { /* 4byte