]> granicus.if.org Git - php/commitdiff
Fix #78346: strip_tags no longer handling nested php tags
authorChristoph M. Becker <cmbecker69@gmx.de>
Fri, 2 Aug 2019 15:03:20 +0000 (17:03 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Fri, 2 Aug 2019 15:03:20 +0000 (17:03 +0200)
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.

NEWS
ext/standard/string.c
ext/standard/tests/strings/bug78346.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 41267187e06027d08fadbf66f5661b1955ca40b3..c4c2a2b4219a3ca6cdd07c7d4ce48d3063a3473e 100644 (file)
--- 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
 
index 6ed6ec2a50d487b3dea0d4fb92cf0f7187a52aee..dde97faf4d10ac93dfa7ea43b351e11ca3ea909a 100644 (file)
@@ -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 (file)
index 0000000..f2c508f
--- /dev/null
@@ -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"