[PHP-DEV] Bug #5975 request

2003-02-05 Thread Keyser Soze
The last patch was core dumping, now it's fixed. It runs fine here in my
system, last php 5 CVS.
The patch is in: http://www.ricesu.com.br/php_dev/patch_new.diff

Please, take a look and apply it if it's ok.


Regards,
Fabricio Olivetti


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DEV] Bug #5975 request

2003-02-04 Thread Keyser Soze

Hi all,

I implemented the BUG #5975 requesting a third parameter in strip_tags, to
disallow the tags in the second parameter instead of allowing then. But
since I don't have CVS account, I would like that someone send me the files
ext/standard/string.c ext/standard/php_string.h ext/standard/file.c to make
a diff, if it's of your interest.

Regards,
Fabricio Olivetti

P.S.: since I'm having a spare time on my job right now, I'd like some
suggestions on what to work on to help PHP community in the meantime.




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Bug #5975 request

2003-02-04 Thread Derick Rethans
On Tue, 4 Feb 2003, Keyser Soze wrote:

 
 Hi all,
 
 I implemented the BUG #5975 requesting a third parameter in strip_tags, to
 disallow the tags in the second parameter instead of allowing then. But
 since I don't have CVS account, I would like that someone send me the files
 ext/standard/string.c ext/standard/php_string.h ext/standard/file.c to make
 a diff, if it's of your interest.

We have anonoymous cvs, just do this to check it out:

cvs -d :pserver:[EMAIL PROTECTED]:/repository login
(password: phpfi)
cvs -d :pserver:[EMAIL PROTECTED]:/repository co php5

regards,
Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Bug #5975 request

2003-02-04 Thread Keyser Soze
Attached it's the patch for strip_tags, it patches 3 files: string.c,
php_string.h and file.c.
It adds a third optional argument as described earlier.

Tested here and it worked fine. Any problems, just contact me.

Regards,
Fabricio Olivetti

- Original Message -
From: Derick Rethans [EMAIL PROTECTED]
To: Keyser Soze [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, February 04, 2003 4:52 PM
Subject: Re: [PHP-DEV] Bug #5975 request



On Tue, 4 Feb 2003, Keyser Soze wrote:


 Hi all,

 I implemented the BUG #5975 requesting a third parameter in strip_tags, to
 disallow the tags in the second parameter instead of allowing then. But
 since I don't have CVS account, I would like that someone send me the
files
 ext/standard/string.c ext/standard/php_string.h ext/standard/file.c to
make
 a diff, if it's of your interest.

We have anonoymous cvs, just do this to check it out:

cvs -d :pserver:[EMAIL PROTECTED]:/repository login
(password: phpfi)
cvs -d :pserver:[EMAIL PROTECTED]:/repository co php5

regards,
Derick

--

-
 Derick Rethans http://derickrethans.nl/
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DEV] Bug #5975 request

2003-02-04 Thread Keyser Soze
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 - 1.296
+++ ext/standard/file.c 4 Feb 2003 19:21:43 -
@@ -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 - 1.69
+++ ext/standard/php_string.h 4 Feb 2003 19:21:43 -
@@ -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 - 1.353
+++ ext/standard/string.c 4 Feb 2003 19:21:43 -
@@ -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


Re: [PHP-DEV] Bug #5975 request

2003-02-04 Thread Derick Rethans
On Tue, 4 Feb 2003, Keyser Soze wrote:

 Sending in plain text:

Got mangled :I Can you put it on the web?

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Bug #5975 request

2003-02-04 Thread Keyser Soze
sure.
http://www.ricesu.com.br/php_dev/patch.diff

i'll delete it tomorrow at 15:00 GMT

Regards,
Fabricio Olivetti

- Original Message - 
From: Derick Rethans [EMAIL PROTECTED]
To: Keyser Soze [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, February 04, 2003 5:44 PM
Subject: Re: [PHP-DEV] Bug #5975 request



On Tue, 4 Feb 2003, Keyser Soze wrote:

 Sending in plain text:

Got mangled :I Can you put it on the web?

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] Bug #5975 request

2003-02-04 Thread Tal Peer
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 - 1.296
+++ ext/standard/file.c 4 Feb 2003 19:21:43 -
@@ -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 - 1.69
+++ ext/standard/php_string.h 4 Feb 2003 19:21:43 -
@@ -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 - 1.353
+++ ext/standard/string.c 4 Feb 2003 19:21:43 -
@@ -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




Re: [PHP-DEV] Bug #5975 request

2003-02-04 Thread Keyser Soze
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 - 1.296
 +++ ext/standard/file.c 4 Feb 2003 19:21:43 -
 @@ -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 - 1.69
 +++ ext/standard/php_string.h 4 Feb 2003 19:21:43 -
 @@ -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 - 1.353
 +++ ext/standard/string.c 4 Feb 2003 19:21:43 -
 @@ -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