From a87ef5e3ddfdb3083c2b62bb25835b74d9a3d083 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 2 Aug 2019 17:03:20 +0200 Subject: [PATCH] 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. --- NEWS | 1 + ext/standard/string.c | 3 +-- ext/standard/tests/strings/bug78346.phpt | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 ext/standard/tests/strings/bug78346.phpt 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-- +\' ?>2'; +var_dump(strip_tags($str)); +?> +--EXPECT-- +string(1) "2" -- 2.40.0