diff --git a/ext/standard/string.c b/ext/standard/string.c index ba361ff5097..8490abf6210 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3413,6 +3413,9 @@ PHPAPI void php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, int while (i < len) { switch (c) { case '<': + if (isspace(*(p + 1))) { + goto reg_char; + } if (state == 0) { lc = '<'; state = 1; @@ -3552,6 +3555,7 @@ PHPAPI void php_strip_tags(char *rbuf, int len, int *stateptr, char *allow, int /* fall-through */ default: +reg_char: if (state == 0) { *(rp++) = c; } else if (allow && state == 1) { diff --git a/ext/standard/tests/strings/bug21453.phpt b/ext/standard/tests/strings/bug21453.phpt new file mode 100644 index 00000000000..40d89dd1b40 --- /dev/null +++ b/ext/standard/tests/strings/bug21453.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #21453 (handling of non-encoded <) +--FILE-- + + first cell before < first cell after + second cell before < second cell after +"; + + var_dump(strip_tags($test)); +?> +--EXPECT-- +string(80) " + + first cell before < first cell after + second cell before < second cell after +"