Skip to content

Commit ff7ed90

Browse files
author
Julien Pauli
committed
Fix #70720
1 parent db1504d commit ff7ed90

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PHP NEWS
1717
- Session:
1818
. Fixed bug #71122 (Session GC may not remove obsolete session data). (Yasuo)
1919

20+
- Standard:
21+
. Fixed bug #70720 (strip_tags improper php code parsing). (Julien)
22+
2023
17 Dec 2015, PHP 5.6.17
2124

2225
- Core:

ext/standard/string.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4689,6 +4689,9 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
46894689
switch (state) {
46904690
case 1: /* HTML/XML */
46914691
lc = '>';
4692+
if (*(p -1) == '-') {
4693+
break;
4694+
}
46924695
in_q = state = 0;
46934696
if (allow) {
46944697
if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
@@ -4818,7 +4821,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
48184821
* state == 2 (PHP). Switch back to HTML.
48194822
*/
48204823

4821-
if (state == 2 && p > buf+2 && strncasecmp(p-2, "xm", 2) == 0) {
4824+
if (state == 2 && p > buf+2 && strncasecmp(p-4, "<?xm", 4) == 0) {
48224825
state = 1;
48234826
break;
48244827
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #70720 (strip_tags() doesnt handle "xml" correctly)
3+
--FILE--
4+
<?php
5+
var_dump(strip_tags('<?php $dom->test(); ?> this is a test'));
6+
var_dump(strip_tags('<?php $xml->test(); ?> this is a test'));
7+
var_dump(strip_tags('<?xml $xml->test(); ?> this is a test'));
8+
?>
9+
--EXPECTF--
10+
string(15) " this is a test"
11+
string(15) " this is a test"
12+
string(15) " this is a test"

0 commit comments

Comments
 (0)