cvs: /php3 ChangeLog /php3/functions zlib.c
| From: | Stefan Roehrich | Date: | Wed, 22 Sep 1999 07:41:43 +0000 |
| Subject: | cvs: /php3 ChangeLog /php3/functions zlib.c | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-11186@lists.php.net to get a copy of this message | ||
sr Wed Sep 22 03:41:43 1999 EDT
Modified files:
/php3 ChangeLog
/php3/functions zlib.c
Log:
Added optional allowable_tags to gzgetss(), too.
Index: php3/ChangeLog
diff -u php3/ChangeLog:1.767 php3/ChangeLog:1.768
--- php3/ChangeLog:1.767 Tue Sep 21 07:28:47 1999
+++ php3/ChangeLog Wed Sep 22 03:41:43 1999
@@ -4,8 +4,9 @@
???? ??, 1999, Version 3.0.13
- Fixed memory leak in pdf_open_memory_image() (Uwe Steinmann)
- Added FTP support (Andrew Skalski)
-- Added optional allowable_tags arguments to strip_tags() and fgetss() to
- allow you to specify a string of tags that are not to be stripped
+- Added optional allowable_tags arguments to strip_tags(),
+ gzgetss() and fgetss() to allow you to specify a string of tags
+ that are not to be stripped
- Fix longstanding Apache .conf nested directive problem (Rasmus)
- OCI8 fix for fetching empty LOBs (Thies)
- OCI8 supports appending and positioning when saving LOBs (Thies)
Index: php3/functions/zlib.c
diff -u php3/functions/zlib.c:1.19 php3/functions/zlib.c:1.20
--- php3/functions/zlib.c:1.19 Tue Sep 7 05:21:53 1999
+++ php3/functions/zlib.c Wed Sep 22 03:41:43 1999
@@ -22,7 +22,7 @@
| Stefan Röhrich <sr@linux.de> |
+----------------------------------------------------------------------+
*/
-/* $Id: zlib.c,v 1.19 1999/09/07 09:21:53 sr Exp $ */
+/* $Id: zlib.c,v 1.20 1999/09/22 07:41:43 sr Exp $ */
#define IS_EXT_MODULE
#include "php.h"
@@ -477,17 +477,31 @@
/* }}} */
/* Strip any HTML tags while reading */
-/* {{{ proto string gzgetss(int zp, int length)
+/* {{{ proto string gzgetss(int zp, int length [, string allowable_tags])
Get a line from file pointer and strip HTML tags */
void php3_gzgetss(INTERNAL_FUNCTION_PARAMETERS)
{
- pval *fd, *bytes;
+ pval *fd, *bytes, *allow=NULL;
gzFile *zp;
int id, len, br, type;
char *buf, *p, *rbuf, *rp, c, lc;
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &fd, &bytes) == FAILURE) {
- WRONG_PARAM_COUNT;
+ switch(ARG_COUNT(ht)) {
+ case 2:
+ if (getParameters(ht, 2, &fd, &bytes) == FAILURE) {
+ RETURN_FALSE;
+ }
+ break;
+ case 3:
+ if (getParameters(ht, 3, &fd, &bytes, &allow) == FAILURE) {
+ RETURN_FALSE;
+ }
+ convert_to_string(allow);
+ break;
+ default:
+ WRONG_PARAM_COUNT;
+ /* NOTREACHED */
+ break;
}
convert_to_long(fd);
@@ -509,87 +523,12 @@
efree(buf);
RETURN_FALSE;
}
+
+ /* strlen() can be used here since we are doing it on the return
+ of an fgets() anyway */
+ _php3_strip_tags(buf,strlen(buf),GLOBAL(gzgetss_state),allow?allow->value.str.val:NULL);
- rbuf = estrdup(buf);
- c = *buf;
- lc = '\0';
- p = buf;
- rp = rbuf;
- br = 0;
-
- while (c) {
- switch (c) {
- case '<':
- if (ZLIB_GLOBAL(gzgetss_state) == 0) {
- lc = '<';
- ZLIB_GLOBAL(gzgetss_state) = 1;
- }
- break;
-
- case '(':
- if (ZLIB_GLOBAL(gzgetss_state) == 2) {
- if (lc != '\"') {
- lc = '(';
- br++;
- }
- } else if (ZLIB_GLOBAL(gzgetss_state) == 0) {
- *(rp++) = c;
- }
- break;
-
- case ')':
- if (ZLIB_GLOBAL(gzgetss_state) == 2) {
- if (lc != '\"') {
- lc = ')';
- br--;
- }
- } else if (ZLIB_GLOBAL(gzgetss_state) == 0) {
- *(rp++) = c;
- }
- break;
-
- case '>':
- if (ZLIB_GLOBAL(gzgetss_state) == 1) {
- lc = '>';
- ZLIB_GLOBAL(gzgetss_state) = 0;
- } else if (ZLIB_GLOBAL(gzgetss_state) == 2) {
- if (!br && lc != '\"') {
- ZLIB_GLOBAL(gzgetss_state) = 0;
- }
- }
- break;
-
- case '\"':
- if (ZLIB_GLOBAL(gzgetss_state) == 2) {
- if (lc == '\"') {
- lc = '\0';
- } else if (lc != '\\') {
- lc = '\"';
- }
- } else if (ZLIB_GLOBAL(gzgetss_state) == 0) {
- *(rp++) = c;
- }
- break;
-
- case '?':
- if (ZLIB_GLOBAL(gzgetss_state)==1) {
- br=0;
- ZLIB_GLOBAL(gzgetss_state)=2;
- break;
- }
- /* fall-through */
-
- default:
- if (ZLIB_GLOBAL(gzgetss_state) == 0) {
- *(rp++) = c;
- }
- }
- c = *(++p);
- }
- *rp = '\0';
- efree(buf);
- RETVAL_STRING(rbuf,1);
- efree(rbuf);
+ RETURN_STRING(buf,0);
}
/* }}} */