[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Sun, 23 Oct 2011 11:54:34 + Revision: http://svn.php.net/viewvc?view=revision&revision=318341 Log: MFH: removed invalid two byte sequenct for utf-8. Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-10-23 11:54:06 UTC (rev 318340) +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-10-23 11:54:34 UTC (rev 318341) @@ -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
Re: [PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
I thought it was valid in terms of CEF nature of UTF-8, but it turrned out RFC states such sequences that start with F5-F7 are not valid. Thanks for the clarification. Moriyoshi On 2011/10/23, at 20:25, Rui Hirokawa wrote: > Hello, Moriyoshi, > > It is because 0xf5-0xf7 is the invalid four byte UTF-8 sequence. > > ref: http://en.wikipedia.org/wiki/UTF-8 > > Rui > > Moriyoshi Koizumi wrote: >> Rui, what is the reason behind this change? >> >> Moriyoshi >> >> On 2011/10/18, at 23:04, Rui Hirokawa wrote: >> >>> hirokawa Tue, 18 Oct 2011 14:04:13 + >>> >>> Revision: http://svn.php.net/viewvc?view=revision&revision=318184 >>> >>> Log: >>> MFH: fixed byte length of utf-8. >>> >>> Changed paths: >>> U >>> php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c >>> >>> Modified: >>> php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c >>> === >>> --- >>> php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c >>> 2011-10-18 14:03:44 UTC (rev 318183) >>> +++ >>> php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c >>> 2011-10-18 14:04:13 UTC (rev 318184) >>> @@ -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 >> > -- Moriyoshi Koizumi m...@mozo.jp -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
Hello, Moriyoshi, It is because 0xf5-0xf7 is the invalid four byte UTF-8 sequence. ref: http://en.wikipedia.org/wiki/UTF-8 Rui Moriyoshi Koizumi wrote: > Rui, what is the reason behind this change? > > Moriyoshi > > On 2011/10/18, at 23:04, Rui Hirokawa wrote: > >> hirokawa Tue, 18 Oct 2011 14:04:13 + >> >> Revision: http://svn.php.net/viewvc?view=revision&revision=318184 >> >> Log: >> MFH: fixed byte length of utf-8. >> >> Changed paths: >>U >> php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c >> >> Modified: >> php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c >> === >> --- >> php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c >> 2011-10-18 14:03:44 UTC (rev 318183) >> +++ >> php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c >> 2011-10-18 14:04:13 UTC (rev 318184) >> @@ -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 Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
Rui, what is the reason behind this change? Moriyoshi On 2011/10/18, at 23:04, Rui Hirokawa wrote: > hirokawa Tue, 18 Oct 2011 14:04:13 + > > Revision: http://svn.php.net/viewvc?view=revision&revision=318184 > > Log: > MFH: fixed byte length of utf-8. > > Changed paths: >U > php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c > > Modified: > php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c > === > --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c > 2011-10-18 14:03:44 UTC (rev 318183) > +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c > 2011-10-18 14:04:13 UTC (rev 318184) > @@ -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 -- Moriyoshi Koizumi m...@mozo.jp -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Tue, 18 Oct 2011 14:04:13 + Revision: http://svn.php.net/viewvc?view=revision&revision=318184 Log: MFH: fixed byte length of utf-8. Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-10-18 14:03:44 UTC (rev 318183) +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-10-18 14:04:13 UTC (rev 318184) @@ -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/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Wed, 07 Sep 2011 14:30:38 + Revision: http://svn.php.net/viewvc?view=revision&revision=316358 Log: MFH: fixed invalid utf-8 check. Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-09-07 14:30:06 UTC (rev 316357) +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-09-07 14:30:38 UTC (rev 316358) @@ -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/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c mbfilter_utf8_mobile.c
hirokawa Sat, 27 Aug 2011 01:25:24 + Revision: http://svn.php.net/viewvc?view=revision&revision=315599 Log: MFH: corrected valid unicode area. Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c U php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c Modified: php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-27 01:25:10 UTC (rev 315598) +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-27 01:25:24 UTC (rev 315599) @@ -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/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c 2011-08-27 01:25:10 UTC (rev 315598) +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c 2011-08-27 01:25:24 UTC (rev 315599) @@ -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/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Sat, 06 Aug 2011 04:28:26 + Revision: http://svn.php.net/viewvc?view=revision&revision=314360 Log: MFH: improved error handling for ill-formed utf-8 based on the Unicode recommendation. Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-06 04:25:44 UTC (rev 314359) +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-06 04:28:26 UTC (rev 314360) @@ -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/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Sat, 06 Aug 2011 02:22:38 + Revision: http://svn.php.net/viewvc?view=revision&revision=314358 Log: MFH: added ill-formed utf-8 check for 0xED. Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-06 02:22:15 UTC (rev 314357) +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-06 02:22:38 UTC (rev 314358) @@ -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/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Fri, 05 Aug 2011 04:34:16 + Revision: http://svn.php.net/viewvc?view=revision&revision=314303 Log: MFH (added check for invalid utf-8 encoding). Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-05 04:28:24 UTC (rev 314302) +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-05 04:34:16 UTC (rev 314303) @@ -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->cac
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/ mbfilter_utf8.c
hirokawa Thu, 04 Aug 2011 12:51:40 + Revision: http://svn.php.net/viewvc?view=revision&revision=314261 Log: MFH (removed obsolete/invalid 5,6 byte encoding of UTF-8 from mbstring/libmbfl based on Unicode 5.2. Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c Modified: php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-04 12:51:00 UTC (rev 314260) +++ php/php-src/branches/PHP_5_4/ext/mbstring/libmbfl/filters/mbfilter_utf8.c 2011-08-04 12:51:40 UTC (rev 314261) @@ -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, filte