]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.1' into PHP-7.2
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 5 Jul 2018 17:11:25 +0000 (19:11 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 5 Jul 2018 17:11:25 +0000 (19:11 +0200)
1  2 
ext/standard/filters.c

index a2f8125ded5edcc639e91790f8845f9ccf82af43,7115c534b0679d9950683991905b6d88475e3592..55b5a9df51872700115e416719c8aa15032add78
@@@ -172,16 -172,18 +172,18 @@@ static php_stream_filter_factory strfil
  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;
        }
@@@ -242,15 -244,22 +244,17 @@@ static php_stream_filter_ops strfilter_
        "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) {