From 69bab6e5a5c8afba684b5fbde6e005a47408d01e Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 13 May 2019 13:10:24 +0200 Subject: [PATCH] Fix #78003: strip_tags output change since PHP 7.3 A refactoring of the strip tags state machine[1] missed the special treatment of `depth > 0` when a `>` is encountered in state 2 or 3. We re-add it for BC reasons. [1] --- NEWS | 1 + ext/standard/string.c | 8 ++++++++ ext/standard/tests/strings/bug78003.phpt | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 ext/standard/tests/strings/bug78003.phpt diff --git a/NEWS b/NEWS index 56b423a5f3..98c06eb5d1 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,7 @@ PHP NEWS - Standard: . Fixed bug #77931 (Warning for array_map mentions wrong type). (Nikita) + . Fixed bug #78003 (strip_tags output change since PHP 7.3). (cmb) 02 May 2019, PHP 7.3.5 diff --git a/ext/standard/string.c b/ext/standard/string.c index 7404f38982..fe7f64de2e 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -5227,6 +5227,10 @@ state_2: } break; case '>': + if (depth) { + depth--; + break; + } if (in_q) { break; } @@ -5284,6 +5288,10 @@ state_3: c = *p; switch (c) { case '>': + if (depth) { + depth--; + break; + } if (in_q) { break; } diff --git a/ext/standard/tests/strings/bug78003.phpt b/ext/standard/tests/strings/bug78003.phpt new file mode 100644 index 0000000000..4379ca8a71 --- /dev/null +++ b/ext/standard/tests/strings/bug78003.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #78003 (strip_tags output change since PHP 7.3) +--FILE-- +bar>'), + strip_tags('bar>'), + strip_tags('bar>') +); +?> +===DONE=== +--EXPECT-- +string(0) "" +string(0) "" +string(0) "" +===DONE=== -- 2.40.0