case 0x22: /* '"' */
case 0x27: /* '\'' */
- if (state == 2 && prev1 != 0x5C) { /* '\\' */
+ if (state == 4){
+ /* Inside <!-- comment --> */
+ break;
+ } else if (state == 2 && prev1 != 0x5C) { /* '\\' */
if (last == ch) {
last = 0x00;
} else if (last != 0x5C) {
case '"':
case '\'':
- if (state == 2 && *(p-1) != '\\') {
+ if (state == 4) {
+ /* Inside <!-- comment --> */
+ break;
+ } else if (state == 2 && *(p-1) != '\\') {
if (lc == c) {
lc = '\0';
} else if (lc != '\\') {
--- /dev/null
+--TEST--
+Bug #46578 (strip_tags() does not honor end-of-comment when it encounters a single quote)
+--FILE--
+<?php
+
+var_dump(strip_tags('<!-- testing I\'ve been to mars -->foobar'));
+
+var_dump(strip_tags('<a alt="foobar">foo<!-- foo! --></a>bar'));
+
+var_dump(strip_tags('<a alt="foobar"/>foo<?= foo! /* <!-- "cool" --> */ ?>bar'));
+
+var_dump(strip_tags('< ax'));
+
+var_dump(strip_tags('<! a>'));
+
+var_dump(strip_tags('<? ax'));
+
+?>
+--EXPECTF--
+%string|unicode%(6) "foobar"
+%string|unicode%(6) "foobar"
+%string|unicode%(6) "foobar"
+%string|unicode%(4) "< ax"
+%string|unicode%(0) ""
+%string|unicode%(0) ""