I'm using php's tidy library to "clean and repair" some html coming from user input.
Everything works fine, but i'm running into a problem that I can't figure out what its cause is. My code is like this:
$tidy = new tidy();
$tidy_options = array(
'hide-comments' => true,'tidy-mark' => false, 'indent' => false,
'new-blocklevel-tags' => 'article,footer,header,hgroup,output,progress,section,video',
'new-inline-tags' => 'audio,details,time,ruby,rt,rp',
'drop-empty-paras' => false,
'doctype' => '<!DOCTYPE HTML>',
'sort-attributes' => 'none', 'vertical-space' => false,
'output-xhtml' => true,'wrap' => 180,
'wrap-attributes' => false,
'break-before-br' => false,
'show-body-only' => true
);
$data = $tidy->repairString($data, $tidy_options, 'UTF8');
echo $data;
This works for all kinds of input, except when i'm trying to use html for embeding swf files.
So , i try this code:
<object data="http://the_swf_file_url" type="application/x-shockwave-flash" width="853" height="520">
<param name="movie" value="http://the_swf_file_url">
</object>
but repairString stripes off all of it, and returns an empty string.
The strangest thing is that:
-If i enter some text along with the above, so the input is like Hello world<object...>...</object>
then it works fine.
-Or if i specify 'show-body-only' => false
it also works fine!
Any clue Why this is happening? Thanks in advance.
Edit: tried pankar's suggestion with setting preserve-entities to true but had no luck...
The OBJECT element may also appear in the content of the HEAD element.
– Barbette