diff --git a/ext/standard/string.c b/ext/standard/string.c index d9290a05c83..4aa11121346 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4711,6 +4711,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, int *stateptr, const cha size_t pos, i = 0; char *allow_free = NULL; const char *allow_actual; + char is_xml = 0; if (stateptr) state = *stateptr; @@ -4806,7 +4807,10 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, int *stateptr, const cha switch (state) { case 1: /* HTML/XML */ lc = '>'; - in_q = state = 0; + if (is_xml && *(p -1) == '-') { + break; + } + in_q = state = is_xml = 0; if (allow) { if (tp - tbuf >= PHP_TAG_BUF_SIZE) { pos = tp - tbuf; @@ -4935,8 +4939,8 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, int *stateptr, const cha * state == 2 (PHP). Switch back to HTML. */ - if (state == 2 && p > buf+2 && strncasecmp(p-2, "xm", 2) == 0) { - state = 1; + if (state == 2 && p > buf+2 && strncasecmp(p-4, "test(); ?> this is a test')); +var_dump(strip_tags('test(); ?> this is a test')); +var_dump(strip_tags('test(); ?> this is a test')); + +/* "->" case in HTML */ +var_dump(strip_tags(" this is a test")); +?> +--EXPECTF-- +string(15) " this is a test" +string(15) " this is a test" +string(15) " this is a test" +string(15) " this is a test"