I'm trying to only allow certain tags for text that is input through a text editor. I've got the following code that all text is filtered through first:
You don't need to include the closing tags in the allowed tag list. Maybe that's what's confusing things? See if it makes any difference with ''<p><a><ul><li><h1>'.
On a side note, be aware that it won't by itself prevent something like the following if you allow the <p> tag, for instance:
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
You don't need to include the closing tags in the allowed tag list. Maybe that's what's confusing things? See if it makes any difference with ''<p><a><ul><li><h1>'.
On a side note, be aware that it won't by itself prevent something like the following if you allow the <p> tag, for instance:
Have you considered using BBCode, or a WYSIWYG textarea plugin like TinyMCE? It can give you better overall control without you having to reinvent the wheel, so to speak.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Have you considered using BBCode, or a WYSIWYG textarea plugin like TinyMCE? It can give you better overall control without you having to reinvent the wheel, so to speak.
I'm using CKEditor and I don't want the customer to change the fonts because then it screws up the default font-size and makes the site look like crap. I just don't understand why strip_tags doesn't remove those tags. Maybe they're exempt
Have you tried dumping the actual variable being processed right before the call to strip_tags? Is it possible that CKEditor is doing something funky with the mark-up?
In any case, this little test worked fine for me:
PHP Code:
<?php
$text = <<<EOD
<p>This is a <span style='font-family:courier'>test</span></p>
EOD;
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks