Skip to content

Commit a87ef5e

Browse files
committed
Fix #78346: strip_tags no longer handling nested php tags
When the strip tags state machine has been flattened, an if statement has mistakenly been treated as else if. We fix this, and also simplify a bit right away.
1 parent 81efd48 commit a87ef5e

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ PHP NEWS
3333
with invalid length). (Nikita)
3434
. Fixed bug #78326 (improper memory deallocation on stream_get_contents()
3535
with fixed length buffer). (Albert Casademont)
36+
. Fixed bug #78346 (strip_tags no longer handling nested php tags). (cmb)
3637

3738
01 Aug 2019, PHP 7.3.8
3839

ext/standard/string.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5271,8 +5271,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, uint8_t *stateptr, const
52715271
} else if (lc != '\\') {
52725272
lc = c;
52735273
}
5274-
} else {
5275-
if (p != buf && *(p-1) != '\\' && (!in_q || *p == in_q)) {
5274+
if (p != buf && (!in_q || *p == in_q)) {
52765275
if (in_q) {
52775276
in_q = 0;
52785277
} else {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Bug #78346 (strip_tags no longer handling nested php tags)
3+
--FILE--
4+
<?php
5+
$str = '<?= \'<?= 1 ?>\' ?>2';
6+
var_dump(strip_tags($str));
7+
?>
8+
--EXPECT--
9+
string(1) "2"

0 commit comments

Comments
 (0)