typedef struct _php_strip_tags_filter {
const char *allowed_tags;
int allowed_tags_len;
- int state;
- int persistent;
+ uint8_t state;
+ uint8_t persistent;
} php_strip_tags_filter;
- static int php_strip_tags_filter_ctor(php_strip_tags_filter *inst, const char *allowed_tags, size_t allowed_tags_len, int persistent)
+ static int php_strip_tags_filter_ctor(php_strip_tags_filter *inst, zend_string *allowed_tags, int persistent)
{
if (allowed_tags != NULL) {
- inst->allowed_tags = pemalloc(allowed_tags_len, persistent);
- memcpy((char *)inst->allowed_tags, allowed_tags, allowed_tags_len);
- inst->allowed_tags_len = (int)allowed_tags_len;
+ if (NULL == (inst->allowed_tags = pemalloc(ZSTR_LEN(allowed_tags) + 1, persistent))) {
+ return FAILURE;
+ }
+ memcpy((char *)inst->allowed_tags, ZSTR_VAL(allowed_tags), ZSTR_LEN(allowed_tags) + 1);
+ inst->allowed_tags_len = (int)ZSTR_LEN(allowed_tags);
} else {
inst->allowed_tags = NULL;
}
"string.strip_tags"
};
-static php_stream_filter *strfilter_strip_tags_create(const char *filtername, zval *filterparams, int persistent)
+static php_stream_filter *strfilter_strip_tags_create(const char *filtername, zval *filterparams, uint8_t persistent)
{
php_strip_tags_filter *inst;
- smart_str tags_ss = {0};
+ php_stream_filter *filter = NULL;
+ zend_string *allowed_tags = NULL;;
inst = pemalloc(sizeof(php_strip_tags_filter), persistent);
- if (inst == NULL) { /* it's possible pemalloc returns NULL
- instead of causing it to bail out */
- return NULL;
- }
-
if (filterparams != NULL) {
if (Z_TYPE_P(filterparams) == IS_ARRAY) {
+ smart_str tags_ss = {0};
zval *tmp;
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(filterparams), tmp) {