Skip to content

Commit 69bab6e

Browse files
committed
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] <http://git.php.net/?p=php-src.git;a=commit;h=5cf64742773ddbf9af69d962a4d12b567fcf0084>
1 parent bec68d5 commit 69bab6e

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ PHP NEWS
3535

3636
- Standard:
3737
. Fixed bug #77931 (Warning for array_map mentions wrong type). (Nikita)
38+
. Fixed bug #78003 (strip_tags output change since PHP 7.3). (cmb)
3839

3940
02 May 2019, PHP 7.3.5
4041

ext/standard/string.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5227,6 +5227,10 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, uint8_t *stateptr, const
52275227
}
52285228
break;
52295229
case '>':
5230+
if (depth) {
5231+
depth--;
5232+
break;
5233+
}
52305234
if (in_q) {
52315235
break;
52325236
}
@@ -5284,6 +5288,10 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, uint8_t *stateptr, const
52845288
c = *p;
52855289
switch (c) {
52865290
case '>':
5291+
if (depth) {
5292+
depth--;
5293+
break;
5294+
}
52875295
if (in_q) {
52885296
break;
52895297
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #78003 (strip_tags output change since PHP 7.3)
3+
--FILE--
4+
<?php
5+
var_dump(
6+
strip_tags('<foo<>bar>'),
7+
strip_tags('<foo<!>bar>'),
8+
strip_tags('<foo<?>bar>')
9+
);
10+
?>
11+
===DONE===
12+
--EXPECT--
13+
string(0) ""
14+
string(0) ""
15+
string(0) ""
16+
===DONE===

0 commit comments

Comments
 (0)