]> granicus.if.org Git - php/commitdiff
Fix #78003: strip_tags output change since PHP 7.3
authorChristoph M. Becker <cmbecker69@gmx.de>
Mon, 13 May 2019 11:10:24 +0000 (13:10 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Mon, 13 May 2019 11:10:24 +0000 (13:10 +0200)
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] <http://git.php.net/?p=php-src.git;a=commit;h=5cf64742773ddbf9af69d962a4d12b567fcf0084>

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

diff --git a/NEWS b/NEWS
index 56b423a5f32847a8e297d4fb6ed3d9756c69168f..98c06eb5d14047702eec74ae807e98042a001bed 100644 (file)
--- 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
 
index 7404f38982ef71f8f7bc5abf075300400d8f6533..fe7f64de2ec71bea98b885cedb2096090730c344 100644 (file)
@@ -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 (file)
index 0000000..4379ca8
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #78003 (strip_tags output change since PHP 7.3)
+--FILE--
+<?php
+var_dump(
+    strip_tags('<foo<>bar>'),
+    strip_tags('<foo<!>bar>'),
+    strip_tags('<foo<?>bar>')
+);
+?>
+===DONE===
+--EXPECT--
+string(0) ""
+string(0) ""
+string(0) ""
+===DONE===