cvs: php4 /ext/standard file.c file.h php_string.h string.c /ext/zlib zlib.c /main php_streams.h
| From: | Wez Furlong | Date: | Wed, 20 Mar 2002 14:38:14 +0000 |
| Subject: | cvs: php4 /ext/standard file.c file.h php_string.h string.c /ext/zlib zlib.c /main php_streams.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-10484@lists.php.net to get a copy of this message | ||
wez Wed Mar 20 09:38:14 2002 EDT
Modified files:
/php4/ext/standard file.c file.h php_string.h string.c
/php4/ext/zlib zlib.c
/php4/main php_streams.h
Log:
Make state parameter of php_strip_tags passed by reference.
Move state tracking to stream structure.
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.217 php4/ext/standard/file.c:1.218
--- php4/ext/standard/file.c:1.217 Wed Mar 20 09:21:28 2002
+++ php4/ext/standard/file.c Wed Mar 20 09:38:10 2002
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.217 2002/03/20 14:21:28 wez Exp $ */
+/* $Id: file.c,v 1.218 2002/03/20 14:38:10 wez Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -124,7 +124,6 @@
static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC)
{
zend_hash_init(&FG(ht_persistent_socks), 0, NULL, NULL, 1);
- FG(fgetss_state) = 0;
FG(pclose_ret) = 0;
FG(def_chunk_size) = PHP_SOCK_CHUNK_SIZE;
}
@@ -592,7 +591,6 @@
if (stream == NULL) {
RETURN_FALSE;
}
- FG(fgetss_state) = 0;
php_stream_to_zval(stream, return_value);
@@ -973,7 +971,7 @@
zval **fd, **bytes, **allow=NULL;
int len, type;
char *buf;
- void *what;
+ php_stream *stream;
char *allowed_tags=NULL;
int allowed_tags_len=0;
@@ -997,8 +995,8 @@
break;
}
- what = zend_fetch_resource(fd TSRMLS_CC, -1, "File-Handle", &type, 1, le_stream);
- ZEND_VERIFY_RESOURCE(what);
+ stream = zend_fetch_resource(fd TSRMLS_CC, -1, "File-Handle", &type, 1, le_stream);
+ ZEND_VERIFY_RESOURCE(stream);
convert_to_long_ex(bytes);
len = Z_LVAL_PP(bytes);
@@ -1011,13 +1009,13 @@
/*needed because recv doesnt set null char at end*/
memset(buf, 0, len + 1);
- if (php_stream_gets((php_stream *) what, buf, len) == NULL) {
+ if (php_stream_gets(stream, buf, len) == NULL) {
efree(buf);
RETURN_FALSE;
}
/* strlen() can be used here since we are doing it on the return of an fgets() anyway */
- php_strip_tags(buf, strlen(buf), FG(fgetss_state), allowed_tags, allowed_tags_len);
+ php_strip_tags(buf, strlen(buf), &stream->fgetss_state, allowed_tags, allowed_tags_len);
RETURN_STRING(buf, 0);
}
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.55 php4/ext/standard/file.h:1.56
--- php4/ext/standard/file.h:1.55 Tue Mar 19 12:48:57 2002
+++ php4/ext/standard/file.h Wed Mar 20 09:38:11 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.h,v 1.55 2002/03/19 17:48:57 wez Exp $ */
+/* $Id: file.h,v 1.56 2002/03/20 14:38:11 wez Exp $ */
/* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
@@ -105,7 +105,6 @@
php_meta_tags_token php_next_meta_token(php_meta_tags_data * TSRMLS_DC);
typedef struct {
- int fgetss_state;
int pclose_ret;
HashTable ht_persistent_socks;
size_t def_chunk_size;
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.55 php4/ext/standard/php_string.h:1.56
--- php4/ext/standard/php_string.h:1.55 Thu Feb 28 03:26:48 2002
+++ php4/ext/standard/php_string.h Wed Mar 20 09:38:11 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_string.h,v 1.55 2002/02/28 08:26:48 sebastian Exp $ */
+/* $Id: php_string.h,v 1.56 2002/03/20 14:38:11 wez Exp $ */
/* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
@@ -115,7 +115,7 @@
int needle_len, char *str, int str_len, int *_new_length);
PHPAPI void php_trim(zval **str, zval *return_value, int mode TSRMLS_DC);
PHPAPI void php_trim2(zval **str, zval **what, 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);
PHPAPI int php_char_to_str(char *str, uint len, char from, char *to, int to_len, pval *result);
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.265 php4/ext/standard/string.c:1.266
--- php4/ext/standard/string.c:1.265 Sun Mar 17 21:00:53 2002
+++ php4/ext/standard/string.c Wed Mar 20 09:38:11 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.265 2002/03/18 02:00:53 jimw Exp $ */
+/* $Id: string.c,v 1.266 2002/03/20 14:38:11 wez Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -3095,7 +3095,7 @@
}
convert_to_string_ex(str);
buf = estrndup(Z_STRVAL_PP(str), Z_STRLEN_PP(str));
- php_strip_tags(buf, Z_STRLEN_PP(str), 0, allowed_tags, allowed_tags_len);
+ php_strip_tags(buf, Z_STRLEN_PP(str), NULL, allowed_tags, allowed_tags_len);
RETURN_STRING(buf, 0);
}
/* }}} */
@@ -3286,10 +3286,14 @@
swm: Added ability to strip <?xml tags without assuming it PHP
code.
*/
-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 *stateptr, char *allow, int allow_len)
{
char *tbuf, *buf, *p, *tp, *rp, c, lc;
int br, i=0;
+ int state;
+
+ if (stateptr)
+ state = *stateptr;
buf = estrndup(rbuf, len);
c = *buf;
@@ -3417,6 +3421,8 @@
*rp = '\0';
efree(buf);
if(allow) efree(tbuf);
+ if (stateptr)
+ *stateptr = state;
}
/* }}} */
Index: php4/ext/zlib/zlib.c
diff -u php4/ext/zlib/zlib.c:1.117 php4/ext/zlib/zlib.c:1.118
--- php4/ext/zlib/zlib.c:1.117 Wed Mar 20 09:21:29 2002
+++ php4/ext/zlib/zlib.c Wed Mar 20 09:38:13 2002
@@ -18,7 +18,7 @@
| Jade Nicoletti <nicoletti@nns.ch> |
+----------------------------------------------------------------------+
*/
-/* $Id: zlib.c,v 1.117 2002/03/20 14:21:29 wez Exp $ */
+/* $Id: zlib.c,v 1.118 2002/03/20 14:38:13 wez Exp $ */
#define IS_EXT_MODULE
#ifdef HAVE_CONFIG_H
@@ -517,7 +517,7 @@
}
/* strlen() can be used here since we are doing it on the return of an fgets() anyway */
- php_strip_tags(buf, strlen(buf), ZLIBG(gzgetss_state), allowed_tags, allowed_tags_len);
+ php_strip_tags(buf, strlen(buf), &ZLIBG(gzgetss_state), allowed_tags, allowed_tags_len);
RETURN_STRING(buf, 0);
}
Index: php4/main/php_streams.h
diff -u php4/main/php_streams.h:1.23 php4/main/php_streams.h:1.24
--- php4/main/php_streams.h:1.23 Wed Mar 20 09:21:30 2002
+++ php4/main/php_streams.h Wed Mar 20 09:38:13 2002
@@ -118,6 +118,7 @@
void *wrapperthis; /* convenience pointer for a instance of a wrapper */
zval *wrapperdata; /* fgetwrapperdata retrieves this */
+ int fgetss_state; /* for fgetss to handle multiline tags */
int is_persistent;
char mode[16]; /* "rwb" etc. ala stdio */
int rsrc_id; /* used for auto-cleanup */