summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-08-02 17:03:20 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2019-08-02 17:03:20 +0200
commita87ef5e3ddfdb3083c2b62bb25835b74d9a3d083 (patch)
treeb602d6b043a6994c3d3c4ba1a6304ae042644e4b
parent81efd489db387a6ab3c9bcafdfd65e304cf2ab08 (diff)
downloadphp-git-a87ef5e3ddfdb3083c2b62bb25835b74d9a3d083.tar.gz
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.
-rw-r--r--NEWS1
-rw-r--r--ext/standard/string.c3
-rw-r--r--ext/standard/tests/strings/bug78346.phpt9
3 files changed, 11 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 41267187e0..c4c2a2b421 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 6ed6ec2a50..dde97faf4d 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -5271,8 +5271,7 @@ state_2:
} 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 {
diff --git a/ext/standard/tests/strings/bug78346.phpt b/ext/standard/tests/strings/bug78346.phpt
new file mode 100644
index 0000000000..f2c508f09b
--- /dev/null
+++ b/ext/standard/tests/strings/bug78346.phpt
@@ -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"