[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
moriyoshi Mon Aug 18 03:26:40 2008 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: - MFH: beware of signedness http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.21r2=1.111.2.2.2.22diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.21 php-src/ext/standard/html.c:1.111.2.2.2.22 --- php-src/ext/standard/html.c:1.111.2.2.2.21 Sun Aug 10 13:26:25 2008 +++ php-src/ext/standard/html.c Mon Aug 18 03:26:40 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.21 2008/08/10 13:26:25 lbarnaud Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.22 2008/08/18 03:26:40 moriyoshi Exp $ */ /* * HTML entity resources: @@ -1203,21 +1203,21 @@ if (*s == 'x' || *s == 'X') { s++; while (s e) { - if (!isxdigit(*s++)) { + if (!isxdigit((int)*(unsigned char *)s++)) { goto encode_amp; } } /* Dec (#90;)*/ } else { while (s e) { - if (!isdigit(*s++)) { + if (!isdigit((int)*(unsigned char *)s++)) { goto encode_amp; } } } } else { /* text entities */ while (s e) { - if (!isalnum(*s++)) { + if (!isalnum((int)*(unsigned char *)s++)) { goto encode_amp; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
janiTue Dec 11 11:29:37 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: MFH: fix error displaying http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.15r2=1.111.2.2.2.16diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.15 php-src/ext/standard/html.c:1.111.2.2.2.16 --- php-src/ext/standard/html.c:1.111.2.2.2.15 Wed Oct 3 04:53:05 2007 +++ php-src/ext/standard/html.c Tue Dec 11 11:29:37 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.15 2007/10/03 04:53:05 stas Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.16 2007/12/11 11:29:37 jani Exp $ */ /* * HTML entity resources: @@ -1136,9 +1136,7 @@ if(status == FAILURE) { /* invalid MB sequence */ efree(replaced); - if(!PG(display_errors)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid multibyte sequence in argument); - } + php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid multibyte sequence in argument); *newlen = 0; return STR_EMPTY_ALLOC(); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
janiTue Dec 11 12:26:16 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: MFH:- Revert previous patch, it was correct to do this, error is logged if logging is enabled http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.16r2=1.111.2.2.2.17diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.16 php-src/ext/standard/html.c:1.111.2.2.2.17 --- php-src/ext/standard/html.c:1.111.2.2.2.16 Tue Dec 11 11:29:37 2007 +++ php-src/ext/standard/html.c Tue Dec 11 12:26:16 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.16 2007/12/11 11:29:37 jani Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.17 2007/12/11 12:26:16 jani Exp $ */ /* * HTML entity resources: @@ -1136,7 +1136,9 @@ if(status == FAILURE) { /* invalid MB sequence */ efree(replaced); - php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid multibyte sequence in argument); + if(!PG(display_errors)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid multibyte sequence in argument); + } *newlen = 0; return STR_EMPTY_ALLOC(); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
stasWed Oct 3 04:53:06 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: do not accept partial multibyte sequences in html* functions http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.14r2=1.111.2.2.2.15diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.14 php-src/ext/standard/html.c:1.111.2.2.2.15 --- php-src/ext/standard/html.c:1.111.2.2.2.14 Sun May 27 15:57:11 2007 +++ php-src/ext/standard/html.c Wed Oct 3 04:53:05 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.14 2007/05/27 15:57:11 nlopess Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.15 2007/10/03 04:53:05 stas Exp $ */ /* * HTML entity resources: @@ -484,18 +484,29 @@ }\ mbseq[mbpos++] = (mbchar); } +#define CHECK_LEN(pos, chars_need) \ + if((str_len - (pos)) chars_need) {\ + *status = FAILURE; \ + return 0; \ + } + /* {{{ get_next_char */ inline static unsigned short get_next_char(enum entity_charset charset, unsigned char * str, + int str_len, int * newpos, unsigned char * mbseq, - int * mbseqlen) + int * mbseqlen, + int *status) { int pos = *newpos; int mbpos = 0; int mbspace = *mbseqlen; unsigned short this_char = str[pos++]; + unsigned char next_char; + + *status = SUCCESS; if (mbspace = 0) { *mbseqlen = 0; @@ -517,6 +528,10 @@ do { if (this_char 0x80) { more = 0; + if(stat) { + /* we didn't finish the UTF sequence correctly */ + *status = FAILURE; + } break; } else if (this_char 0xc0) { switch (stat) { @@ -555,6 +570,7 @@ break; default: /* invalid */ + *status = FAILURE; more = 0; } } @@ -562,21 +578,27 @@ else if (this_char 0xe0) { stat = 0x10;/* 2 byte */ utf = (this_char 0x1f) 6; + CHECK_LEN(pos, 1); } else if (this_char 0xf0) { stat = 0x20;/* 3 byte */ utf = (this_char 0xf) 12; + CHECK_LEN(pos, 2); } else if (this_char 0xf8) { stat = 0x30;/* 4 byte */ utf = (this_char 0x7) 18; + CHECK_LEN(pos, 3); } else if (this_char 0xfc) { stat = 0x40;/* 5 byte */ utf = (this_char 0x3) 24; + CHECK_LEN(pos, 4); } else if (this_char 0xfe) { stat = 0x50;/* 6 byte */ utf = (this_char 0x1) 30; + CHECK_LEN(pos, 5); } else { /* invalid; bail */ more = 0; + *status = FAILURE; break; } @@ -594,7 +616,8 @@ /* check if this is the first of a 2-byte sequence */ if (this_char = 0xa1 this_char = 0xfe) {
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
nlopess Sun May 27 15:45:18 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: fix the new 'no-double-encoding' feature of htmlspecialchars() (the length for char search was wrong. this could lead to crashes..) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.12r2=1.111.2.2.2.13diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.12 php-src/ext/standard/html.c:1.111.2.2.2.13 --- php-src/ext/standard/html.c:1.111.2.2.2.12 Fri May 25 14:09:02 2007 +++ php-src/ext/standard/html.c Sun May 27 15:45:18 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.12 2007/05/25 14:09:02 bjori Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.13 2007/05/27 15:45:18 nlopess Exp $ */ /* * HTML entity resources: @@ -1153,7 +1153,7 @@ memcpy(replaced + len, amp;, sizeof(amp;) - 1); len += sizeof(amp;) - 1; } else { - char *e = memchr(old + i, ';', len - i); + char *e = memchr(old + i, ';', oldlen - i); char *s = old + i + 1; if (!e || (e - s) 10) { /* minor optimization to avoid entities over 10 chars in length */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c /ext/standard/tests/strings htmlentities18.phpt
nlopess Sun May 27 15:57:11 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c /php-src/ext/standard/tests/strings htmlentities18.phpt Log: fix handling of amp; by htmlentities 'no-double-encode' expand the test cases http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.13r2=1.111.2.2.2.14diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.13 php-src/ext/standard/html.c:1.111.2.2.2.14 --- php-src/ext/standard/html.c:1.111.2.2.2.13 Sun May 27 15:45:18 2007 +++ php-src/ext/standard/html.c Sun May 27 15:57:11 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.13 2007/05/27 15:45:18 nlopess Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.14 2007/05/27 15:57:11 nlopess Exp $ */ /* * HTML entity resources: @@ -1154,7 +1154,7 @@ len += sizeof(amp;) - 1; } else { char *e = memchr(old + i, ';', oldlen - i); - char *s = old + i + 1; + char *s = old + i; if (!e || (e - s) 10) { /* minor optimization to avoid entities over 10 chars in length */ goto encode_amp; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/htmlentities18.phpt?r1=1.1.2.1r2=1.1.2.2diff_format=u Index: php-src/ext/standard/tests/strings/htmlentities18.phpt diff -u php-src/ext/standard/tests/strings/htmlentities18.phpt:1.1.2.1 php-src/ext/standard/tests/strings/htmlentities18.phpt:1.1.2.2 --- php-src/ext/standard/tests/strings/htmlentities18.phpt:1.1.2.1 Tue May 22 12:37:00 2007 +++ php-src/ext/standard/tests/strings/htmlentities18.phpt Sun May 27 15:57:11 2007 @@ -9,6 +9,9 @@ ; amp #a; 9;, kffjadfdhsjfhjasdhffasdfas;, #8787978789, + , + amp;, + abamp;, ); foreach ($tests as $test) { @@ -23,9 +26,15 @@ string(13) abcamp;sfdsa string(33) test#043;s amp; some more #68; string(33) test#043;s amp; some more #68; -string(20) ; amp;amp #a; 9; -string(20) ; amp;amp #a; 9; +string(24) ; amp;amp amp;#a; 9; +string(24) ; amp;amp amp;#a; 9; string(32) amp;kffjadfdhsjfhjasdhffasdfas; string(32) amp;kffjadfdhsjfhjasdhffasdfas; string(16) amp;#8787978789 string(16) amp;#8787978789 +string(5) amp; +string(5) amp; +string(15) amp;amp;amp; +string(15) amp;amp;amp; +string(17) amp;abamp;amp; +string(17) amp;abamp;amp; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
bjori Fri May 25 14:09:02 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: Allow skipping hint_charset (fixes ext/standard/tests/strings/htmlentities18.phpt) http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.11r2=1.111.2.2.2.12diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.11 php-src/ext/standard/html.c:1.111.2.2.2.12 --- php-src/ext/standard/html.c:1.111.2.2.2.11 Tue May 22 15:38:27 2007 +++ php-src/ext/standard/html.c Fri May 25 14:09:02 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.11 2007/05/22 15:38:27 bjori Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.12 2007/05/25 14:09:02 bjori Exp $ */ /* * HTML entity resources: @@ -1224,7 +1224,7 @@ char *replaced; zend_bool double_encode = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|lsb, str, str_len, quote_style, hint_charset, hint_charset_len, double_encode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|ls!b, str, str_len, quote_style, hint_charset, hint_charset_len, double_encode) == FAILURE) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
iliaa Sat Feb 24 17:18:24 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: Eliminate strncpy() and simplify code http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.7r2=1.111.2.2.2.8diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.7 php-src/ext/standard/html.c:1.111.2.2.2.8 --- php-src/ext/standard/html.c:1.111.2.2.2.7 Wed Feb 21 03:59:05 2007 +++ php-src/ext/standard/html.c Sat Feb 24 17:18:24 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.7 2007/02/21 03:59:05 iliaa Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.8 2007/02/24 17:18:24 iliaa Exp $ */ /* * HTML entity resources: @@ -912,12 +912,10 @@ if (entity_map[j].table[k - entity_map[j].basechar] == NULL) continue; - entity[0] = ''; - entity_length = strlen(entity_map[j].table[k - entity_map[j].basechar]); - strncpy(entity[1], entity_map[j].table[k - entity_map[j].basechar], sizeof(entity) - 2); - entity[entity_length+1] = ';'; - entity[entity_length+2] = '\0'; - entity_length += 2; + entity_length = snprintf(entity, sizeof(entity), %s;, entity_map[j].table[k - entity_map[j].basechar]); + if (entity_length = sizeof(entity)) { + continue; + } /* When we have MBCS entities in the tables above, this will need to handle it */ replacement_len = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
iliaa Wed Feb 21 03:59:05 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: Use strlcpy() rather then strcpy() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.6r2=1.111.2.2.2.7diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.6 php-src/ext/standard/html.c:1.111.2.2.2.7 --- php-src/ext/standard/html.c:1.111.2.2.2.6 Thu Jan 18 16:21:32 2007 +++ php-src/ext/standard/html.c Wed Feb 21 03:59:05 2007 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.6 2007/01/18 16:21:32 tony2001 Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.7 2007/02/21 03:59:05 iliaa Exp $ */ /* * HTML entity resources: @@ -1138,7 +1138,7 @@ } replaced[len++] = ''; - strcpy(replaced + len, rep); + strlcpy(replaced + len, rep, maxlen); len += l; replaced[len++] = ';'; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
tony2001Thu Dec 21 01:14:30 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.3r2=1.111.2.2.2.4diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.3 php-src/ext/standard/html.c:1.111.2.2.2.4 --- php-src/ext/standard/html.c:1.111.2.2.2.3 Wed Nov 1 01:55:11 2006 +++ php-src/ext/standard/html.c Thu Dec 21 01:14:30 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.3 2006/11/01 01:55:11 iliaa Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.4 2006/12/21 01:14:30 tony2001 Exp $ */ /* * HTML entity resources: @@ -948,7 +948,8 @@ default: php_error_docref(NULL TSRMLS_CC, E_WARNING, cannot yet handle MBCS!); - return 0; + efree(ret); + return NULL; } if (php_memnstr(ret, entity, entity_length, ret+retlen)) { @@ -1308,7 +1309,10 @@ } replaced = php_unescape_html_entities(str, str_len, len, 1, quote_style, hint_charset TSRMLS_CC); - RETVAL_STRINGL(replaced, len, 0); + if (replaced) { + RETURN_STRINGL(replaced, len, 0); + } + RETURN_FALSE; } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
iliaa Wed Nov 1 01:55:11 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: Added missing boundary checks. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.2r2=1.111.2.2.2.3diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2.2.2 php-src/ext/standard/html.c:1.111.2.2.2.3 --- php-src/ext/standard/html.c:1.111.2.2.2.2 Mon Oct 2 07:58:13 2006 +++ php-src/ext/standard/html.c Wed Nov 1 01:55:11 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2.2.2 2006/10/02 07:58:13 bjori Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.3 2006/11/01 01:55:11 iliaa Exp $ */ /* * HTML entity resources: @@ -1105,7 +1105,7 @@ matches_map = 0; - if (len + 9 maxlen) + if (len + 16 maxlen) replaced = erealloc (replaced, maxlen += 128); if (all) { @@ -1130,9 +1130,15 @@ } if (matches_map) { + int l = strlen(rep); + /* increase the buffer size */ + if (len + 2 + l = maxlen) { + replaced = erealloc(replaced, maxlen += 128); + } + replaced[len++] = ''; strcpy(replaced + len, rep); - len += strlen(rep); + len += l; replaced[len++] = ';'; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/standard html.c
tony2001Tue Aug 15 15:09:38 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard html.c Log: MFH: don't try to use auto, none and pass charsets returned from mbstring http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2r2=1.111.2.2.2.1diff_format=u Index: php-src/ext/standard/html.c diff -u php-src/ext/standard/html.c:1.111.2.2 php-src/ext/standard/html.c:1.111.2.2.2.1 --- php-src/ext/standard/html.c:1.111.2.2 Sat Feb 25 21:32:11 2006 +++ php-src/ext/standard/html.c Tue Aug 15 15:09:38 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: html.c,v 1.111.2.2 2006/02/25 21:32:11 rasmus Exp $ */ +/* $Id: html.c,v 1.111.2.2.2.1 2006/08/15 15:09:38 tony2001 Exp $ */ /* * HTML entity resources: @@ -756,6 +756,15 @@ charset_hint = Z_STRVAL_P(uf_result); len = Z_STRLEN_P(uf_result); + if (len == 4) { /* sizeof(none|auto|pass)-1 */ + if (!memcmp(pass, charset_hint, sizeof(pass) - 1) || + !memcmp(auto, charset_hint, sizeof(auto) - 1) || + !memcmp(none, charset_hint, sizeof(none) - 1)) { + + charset_hint = NULL; + len = 0; + } + } goto det_charset; } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php