mirror of
https://github.com/php/php-src.git
synced 2025-08-19 17:04:47 +02:00
- Fixed bug #46578 (strip_tags() does not honor end-of-comment when it encounters a single quote)
This commit is contained in:
parent
7397249d2e
commit
3b06b39d54
2 changed files with 33 additions and 2 deletions
|
@ -6538,7 +6538,10 @@ PHPAPI int php_u_strip_tags(UChar *rbuf, int len, int *stateptr, UChar *allow, i
|
||||||
|
|
||||||
case 0x22: /* '"' */
|
case 0x22: /* '"' */
|
||||||
case 0x27: /* '\'' */
|
case 0x27: /* '\'' */
|
||||||
if (state == 2 && prev1 != 0x5C) { /* '\\' */
|
if (state == 4){
|
||||||
|
/* Inside <!-- comment --> */
|
||||||
|
break;
|
||||||
|
} else if (state == 2 && prev1 != 0x5C) { /* '\\' */
|
||||||
if (last == ch) {
|
if (last == ch) {
|
||||||
last = 0x00;
|
last = 0x00;
|
||||||
} else if (last != 0x5C) {
|
} else if (last != 0x5C) {
|
||||||
|
@ -6779,7 +6782,10 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
case '\'':
|
case '\'':
|
||||||
if (state == 2 && *(p-1) != '\\') {
|
if (state == 4) {
|
||||||
|
/* Inside <!-- comment --> */
|
||||||
|
break;
|
||||||
|
} else if (state == 2 && *(p-1) != '\\') {
|
||||||
if (lc == c) {
|
if (lc == c) {
|
||||||
lc = '\0';
|
lc = '\0';
|
||||||
} else if (lc != '\\') {
|
} else if (lc != '\\') {
|
||||||
|
|
25
ext/standard/tests/strings/bug46578.phpt
Normal file
25
ext/standard/tests/strings/bug46578.phpt
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
--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) ""
|
Loading…
Add table
Add a link
Reference in a new issue