Skip to content

Commit 6b0b29e

Browse files
author
Julien Pauli
committed
Fix #70720
1 parent b837f20 commit 6b0b29e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

ext/standard/string.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4590,6 +4590,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
45904590
int br, i=0, depth=0, in_q = 0;
45914591
int state = 0, pos;
45924592
char *allow_free = NULL;
4593+
char is_xml = 0;
45934594

45944595
if (stateptr)
45954596
state = *stateptr;
@@ -4689,10 +4690,10 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
46894690
switch (state) {
46904691
case 1: /* HTML/XML */
46914692
lc = '>';
4692-
if (*(p -1) == '-') {
4693+
if (is_xml && *(p -1) == '-') {
46934694
break;
46944695
}
4695-
in_q = state = 0;
4696+
in_q = state = is_xml = 0;
46964697
if (allow) {
46974698
if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
46984699
pos = tp - tbuf;
@@ -4822,7 +4823,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
48224823
*/
48234824

48244825
if (state == 2 && p > buf+2 && strncasecmp(p-4, "<?xm", 4) == 0) {
4825-
state = 1;
4826+
state = 1; is_xml=1;
48264827
break;
48274828
}
48284829

ext/standard/tests/strings/bug70720.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ Bug #70720 (strip_tags() doesnt handle "xml" correctly)
55
var_dump(strip_tags('<?php $dom->test(); ?> this is a test'));
66
var_dump(strip_tags('<?php $xml->test(); ?> this is a test'));
77
var_dump(strip_tags('<?xml $xml->test(); ?> this is a test'));
8+
9+
/* "->" case in HTML */
10+
var_dump(strip_tags("<span class=sf-dump-> this is a test</span>"));
811
?>
912
--EXPECTF--
1013
string(15) " this is a test"
1114
string(15) " this is a test"
12-
string(15) " this is a test"
15+
string(15) " this is a test"
16+
string(15) " this is a test"

0 commit comments

Comments
 (0)