The new patch is online at:
http://www.ricesu.com.br/php_dev/patch_new.diff
I didnt test it yet, will do it tomorrow at work, but it should be ok. :-)
Anyway it's there for anyone willing to do the tests.
Regards,
Fabricio Olivetti
----- Original Message -----
From: "Tal Peer" <[EMAIL PROTECTED]>
To: "Keyser Soze" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, February 04, 2003 5:57 PM
Subject: Re: [PHP-DEV] Bug #5975 request
Patch looks ok. Just be sure to use zend_parse_parameters instead of
zend_get_parameters and zend_bool instead of an integer (just grep
ext/standard/* for zend_parse_parameters for examples).
Tal
Keyser Soze wrote:
> Sending in plain text:
>
>
> --------------------------------- cut
> here ----------------------------------------
>
>
> ? patch.diff
> ? ext/standard/file_new.c
> ? ext/standard/string_new.c
> Index: ext/standard/file.c
> ===================================================================
> RCS file: /repository/php4/ext/standard/file.c,v
> retrieving revision 1.296
> diff -u -r1.296 file.c
> --- ext/standard/file.c 21 Jan 2003 14:53:17 -0000 1.296
> +++ ext/standard/file.c 4 Feb 2003 19:21:43 -0000
> @@ -1470,7 +1470,7 @@
> }
>
> /* strlen() can be used here since we are doing it on the return of an
> fgets() anyway */
> - php_strip_tags(buf, strlen(buf), &stream->fgetss_state, allowed_tags,
> allowed_tags_len);
> + php_strip_tags(buf, strlen(buf), &stream->fgetss_state, allowed_tags,
> allowed_tags_len,0);
>
> RETURN_STRING(buf, 0);
> }
> Index: ext/standard/php_string.h
> ===================================================================
> RCS file: /repository/php4/ext/standard/php_string.h,v
> retrieving revision 1.69
> diff -u -r1.69 php_string.h
> --- ext/standard/php_string.h 30 Jan 2003 05:00:40 -0000 1.69
> +++ ext/standard/php_string.h 4 Feb 2003 19:21:43 -0000
> @@ -127,7 +127,7 @@
> PHPAPI char *php_str_to_str(char *haystack, int length, char *needle,
> int needle_len, char *str, int str_len, int *_new_length);
> PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval
> *return_value, int mode TSRMLS_DC);
> -PHPAPI void php_strip_tags(char *rbuf, int len, int *state, char *allow,
> int allow_len);
> +PHPAPI void php_strip_tags(char *rbuf, int len, int *state, char *allow,
> int allow_len,int disallow);
> PHPAPI int php_char_to_str(char *str, uint len, char from, char *to, int
> to_len, pval *result);
> PHPAPI void php_implode(zval *delim, zval *arr, zval *return_value);
> PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, int
> limit);
> Index: ext/standard/string.c
> ===================================================================
> RCS file: /repository/php4/ext/standard/string.c,v
> retrieving revision 1.353
> diff -u -r1.353 string.c
> --- ext/standard/string.c 30 Jan 2003 20:09:19 -0000 1.353
> +++ ext/standard/string.c 4 Feb 2003 19:21:43 -0000
> @@ -3248,9 +3248,10 @@
> PHP_FUNCTION(strip_tags)
> {
> char *buf;
> - zval **str, **allow=NULL;
> + zval **str, **allow=NULL, **disa=NULL;
> char *allowed_tags=NULL;
> int allowed_tags_len=0;
> + int disallow=0;
>
> switch (ZEND_NUM_ARGS()) {
> case 1:
> @@ -3266,13 +3267,24 @@
> allowed_tags = Z_STRVAL_PP(allow);
> allowed_tags_len = Z_STRLEN_PP(allow);
> break;
> + case 3:
> + if (zend_get_parameters_ex(3, &str, &allow, &disa) == FAILURE) {
> + RETURN_FALSE;
> + }
> + convert_to_string_ex(allow);
> + allowed_tags = Z_STRVAL_PP(allow);
> + allowed_tags_len = Z_STRLEN_PP(allow);
> + convert_to_boolean_ex(disa);
> + disallow = Z_BVAL_PP(disa);
> + break;
> +
> default:
> WRONG_PARAM_COUNT;
> break;
> }
> convert_to_string_ex(str);
> buf = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
> - php_strip_tags(buf, Z_STRLEN_PP(str), NULL, allowed_tags,
> allowed_tags_len);
> + php_strip_tags(buf, Z_STRLEN_PP(str), NULL, allowed_tags,
> allowed_tags_len,disallow);
> RETURN_STRING(buf, 0);
> }
> /* }}} */
> @@ -3507,7 +3519,7 @@
> swm: Added ability to strip <?xml tags without assuming it PHP
> code.
> */
> -PHPAPI void php_strip_tags(char *rbuf, int len, int *stateptr, char
*allow,
> int allow_len)
> +PHPAPI void php_strip_tags(char *rbuf, int len, int *stateptr, char
*allow,
> int allow_len,int disallow)
> {
> char *tbuf, *buf, *p, *tp, *rp, c, lc;
> int br, i=0, depth=0;
> @@ -3586,10 +3598,19 @@
> if (allow) {
> *(tp++) = '>';
> *tp='\0';
> + if(disallow) {
> +
> + if (!php_tag_find(tbuf, tp-tbuf, allow)) {
> + memcpy(rp, tbuf, tp-tbuf);
> + rp += tp-tbuf;
> + }
> + } else {
> +
> if (php_tag_find(tbuf, tp-tbuf, allow)) {
> memcpy(rp, tbuf, tp-tbuf);
> rp += tp-tbuf;
> }
> + }
> tp = tbuf;
> }
> break;
>
>
>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php