int issock=0;
int socketd=0;
void *what;
+ char *allowed_tags=NULL;
+ int allowed_tags_len=0;
FIL_FETCH();
switch(ARG_COUNT(ht)) {
RETURN_FALSE;
}
convert_to_string_ex(allow);
+ allowed_tags = (*allow)->value.str.val;
+ allowed_tags_len = (*allow)->value.str.len;
break;
default:
WRONG_PARAM_COUNT;
}
/* strlen() can be used here since we are doing it on the return of an fgets() anyway */
- php_strip_tags(buf, strlen(buf), FIL(fgetss_state), allow?(*allow)->value.str.val:NULL);
+ php_strip_tags(buf, strlen(buf), FIL(fgetss_state), allowed_tags, allowed_tags_len);
RETURN_STRING(buf, 0);
}
extern PHPAPI char *php_str_to_str(char *haystack, int length, char *needle,
int needle_len, char *str, int str_len, int *_new_length);
extern PHPAPI void php_trim(pval *str, pval *return_value, int mode);
-extern PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow);
+extern PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow, int allow_len);
extern PHPAPI void php_char_to_str(char *str, uint len, char from, char *to, int to_len, pval *result);
{
char *buf;
zval **str, **allow=NULL;
+ char *allowed_tags=NULL;
+ int allowed_tags_len=0;
switch(ARG_COUNT(ht)) {
case 1:
RETURN_FALSE;
}
convert_to_string_ex(allow);
+ allowed_tags = (*allow)->value.str.val;
+ allowed_tags_len = (*allow)->value.str.len;
break;
default:
WRONG_PARAM_COUNT;
}
convert_to_string_ex(str);
buf = estrdup((*str)->value.str.val);
- php_strip_tags(buf, (*str)->value.str.len, 0, allow?(*allow)->value.str.val:NULL);
+ php_strip_tags(buf, (*str)->value.str.len, 0, allowed_tags, allowed_tags_len);
RETURN_STRING(buf, 0);
}
/* }}} */
in state 1 and when the tag is closed check it against the
allow string to see if we should allow it.
*/
-PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow) {
+PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow, int allow_len)
+{
char *tbuf, *buf, *p, *tp, *rp, c, lc;
int br, i=0;
rp = rbuf;
br = 0;
if(allow) {
- php_strtolower(allow, len);
+ php_strtolower(allow, allow_len);
tbuf = emalloc(PHP_TAG_BUF_SIZE+1);
tp = tbuf;
} else {
gzFile *zp;
int len;
char *buf;
+ char *allowed_tags=NULL;
+ int allowed_tags_len=0;
ZLIBLS_FETCH();
switch(ARG_COUNT(ht)) {
RETURN_FALSE;
}
convert_to_string_ex(allow);
+ allowed_tags = (*allow)->value.str.val;
+ allowed_tags_len = (*allow)->value.str.len;
break;
default:
WRONG_PARAM_COUNT;
}
/* 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), allow?(*allow)->value.str.val:NULL);
+ php_strip_tags(buf, strlen(buf), ZLIBG(gzgetss_state), allowed_tags, allowed_tags_len);
RETURN_STRING(buf, 0);
}