Skip to content

Commit

Permalink
Fix #78346: strip_tags no longer handling nested php tags
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmb69 committed Aug 2, 2019
1 parent 81efd48 commit a87ef5e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ PHP NEWS
with invalid length). (Nikita)
. Fixed bug #78326 (improper memory deallocation on stream_get_contents()
with fixed length buffer). (Albert Casademont)
. Fixed bug #78346 (strip_tags no longer handling nested php tags). (cmb)

01 Aug 2019, PHP 7.3.8

Expand Down
3 changes: 1 addition & 2 deletions ext/standard/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -5271,8 +5271,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, uint8_t *stateptr, const
} else if (lc != '\\') {
lc = c;
}
} else {
if (p != buf && *(p-1) != '\\' && (!in_q || *p == in_q)) {
if (p != buf && (!in_q || *p == in_q)) {
if (in_q) {
in_q = 0;
} else {
Expand Down
9 changes: 9 additions & 0 deletions ext/standard/tests/strings/bug78346.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--TEST--
Bug #78346 (strip_tags no longer handling nested php tags)
--FILE--
<?php
$str = '<?= \'<?= 1 ?>\' ?>2';
var_dump(strip_tags($str));
?>
--EXPECT--
string(1) "2"

0 comments on commit a87ef5e

Please sign in to comment.