strip_tags and tinymce issue

191 Views Asked by At

I have an issue using strip_tags to clean html tags in text coming from tinymce. I have a form where some textarea fields are managed by tinymce and other simple input text.

I need to strip HTML tags from some input in these fields. This works perfecly with standard input text, nothingh happens with text coming from Tinymce. Here a part of the code:

//from input text

$title = $_POST['title'] ;

//from  text area loaded by tynymce

$shortcontent = $_POST['shortcontent'] ;
$content = $_POST['content'] ;

$title = strip_tags($title) ;   // works

$content = strip_tags($content) ;  //fail

In meantime, SOLVED.

Simply, tags insertet in WYSE mode are always encoded, so html_entity_decode() before strip tags

$content = strip_tags(html_entity_decode($content)) ;
1

There are 1 best solutions below

0
espongha On

You can try to remove the tags on the javascript before posting it on the PHP.

// Store the current selections string/value in a variable and strip it's tags
var content = tinymce.activeEditor.selection.getContent({ format : 'text' });