There seem to be a couple of bugs in the strip_tags() function, one minor
(or at least I know how to circumvent it) and one more serious.

The minor problem is that it treats a "not-equals" sign, "<>", as an empty
tag and strips it, unless it's explicitely set as an allowed tag
(as in strip_tags($text,'<>') ). This is a bit awkward IMHO, but it works.

The other problem is that it fails on the "less than" sign in the text.
The function seems to consider it as an incomplete tag and removes it, as
well as *all text after it to the next ">" sign*. So the following

$t = "Everyone knows that 2 < 3,
        but some people still think that 2 > 3";

$nt = strip_tags($t);
print $nt;

This results in:

%> Everyone knows that 2  3

I've looked in the archives, the notes to the function docs (one of which
appears to relate to the latter problem), as well as the source code for
the function itself, but it's not obvious how the second problem can be
circumvented or fixed. I wonder if someone might have a good, tested regex
that acts similarly to strip_tags (strips all but the allowed tags), or if I
can get some pointers on how to fix the source code.

Thanks !


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to