Fixed bug #40704 (strip_tags() does not handle single quotes correctly)

This commit is contained in:
Ilia Alshanetsky 2007-03-03 15:46:29 +00:00
parent 276aed565e
commit e769e1b49e
2 changed files with 18 additions and 5 deletions

View File

@ -4211,7 +4211,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
switch (state) {
case 1: /* HTML/XML */
lc = '>';
state = 0;
in_q = state = 0;
if (allow) {
tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp);
*(tp++) = '>';
@ -4226,19 +4226,19 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
case 2: /* PHP */
if (!br && lc != '\"' && *(p-1) == '?') {
state = 0;
in_q = state = 0;
tp = tbuf;
}
break;
case 3:
state = 0;
in_q = state = 0;
tp = tbuf;
break;
case 4: /* JavaScript/CSS/etc... */
if (p >= buf + 2 && *(p-1) == '-' && *(p-2) == '-') {
state = 0;
in_q = state = 0;
tp = tbuf;
}
break;
@ -4263,7 +4263,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow,
tp = ((tp-tbuf) >= PHP_TAG_BUF_SIZE ? tbuf: tp);
*(tp++) = c;
}
if (p != buf && *(p-1) != '\\' && (!in_q || *p == in_q)) {
if (state && p != buf && *(p-1) != '\\' && (!in_q || *p == in_q)) {
if (in_q) {
in_q = 0;
} else {

View File

@ -0,0 +1,13 @@
--TEST--
Bug #40704 (strip_tags() does not handle single quotes correctly)
--FILE--
<?php
$html = "<div>Bug ' Trigger</div> Missing Text";
var_dump(strip_tags($html));
echo "Done\n";
?>
--EXPECT--
string(26) "Bug ' Trigger Missing Text"
Done