Skip to content

Commit ff7a694

Browse files
author
Gavin Sherry
committed
Changed php_strip_tags() to check if <? was XML code.
1 parent 30dc081 commit ff7a694

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ext/standard/string.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3190,6 +3190,9 @@ int php_tag_find(char *tag, int len, char *set) {
31903190
When an allow string is passed in we keep track of the string
31913191
in state 1 and when the tag is closed check it against the
31923192
allow string to see if we should allow it.
3193+
3194+
swm: Added ability to strip <?xml tags without assuming it PHP
3195+
code.
31933196
*/
31943197
PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow, int allow_len)
31953198
{
@@ -3286,13 +3289,18 @@ PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow, int allo
32863289
break;
32873290

32883291
case '?':
3289-
if (state==1 && *(p-1)=='<') {
3292+
if (state==1 && *(p-1)=='<' && *(p+1) != 'x'
3293+
&& *(p+2) != 'm' && *(p+3) != 'l') {
3294+
32903295
br=0;
32913296
state=2;
32923297
break;
32933298
}
3294-
/* fall-through */
3299+
/* else, it is xml, since state == 1, lets just fall through
3300+
* to '>'
3301+
*/
32953302

3303+
/* fall-through */
32963304
default:
32973305
if (state == 0) {
32983306
*(rp++) = c;
@@ -3301,7 +3309,7 @@ PHPAPI void php_strip_tags(char *rbuf, int len, int state, char *allow, int allo
33013309
if( (tp-tbuf)>=PHP_TAG_BUF_SIZE ) { /* no buffer overflows */
33023310
tp = tbuf;
33033311
}
3304-
}
3312+
}
33053313
break;
33063314
}
33073315
c = *(++p);

0 commit comments

Comments
 (0)