From f1392da7c756a094e2c40b5364d562358611e665 Mon Sep 17 00:00:00 2001 From: Alex Schneider Date: Wed, 1 Mar 2017 22:08:32 +0100 Subject: [PATCH] We do not want to rely on the infos provided by the user defined callback functions, so we check the length of the user-strings internally --- extcss3/tokenizer/tokenizer.c | 5 +++++ php_extcss3.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/extcss3/tokenizer/tokenizer.c b/extcss3/tokenizer/tokenizer.c index 312fc71..0501e7c 100644 --- a/extcss3/tokenizer/tokenizer.c +++ b/extcss3/tokenizer/tokenizer.c @@ -433,6 +433,11 @@ static inline bool _extcss3_token_add(extcss3_intern *intern, extcss3_token *tok if (intern->base_ctxt != NULL) { if (EXTCSS3_TYPE_IS_MODIFIABLE(token->type) && (intern->modifier.callback != NULL)) { intern->modifier.callback(intern); + + if ((token->user.str != NULL) && (token->user.len > token->data.len)) { + intern->modifier.user_strlen_diff -= token->data.len; + intern->modifier.user_strlen_diff += token->user.len; + } } if (EXTCSS3_SUCCESS != extcss3_ctxt_update(intern, error)) { diff --git a/php_extcss3.c b/php_extcss3.c index 6a1a319..e564f3f 100644 --- a/php_extcss3.c +++ b/php_extcss3.c @@ -181,9 +181,6 @@ static void php_extcss3_modifier_callback(extcss3_intern *intern) intern->last_token->user.str = (char *)calloc(intern->last_token->user.len, sizeof(char)); memcpy(intern->last_token->user.str, Z_STRVAL(retval), Z_STRLEN(retval)); - - intern->modifier.user_strlen_diff -= intern->last_token->data.len; - intern->modifier.user_strlen_diff += intern->last_token->user.len; } }