Welcome! » Log In » Create A New Profile

You tube filter + allowed tags trouble

Posted by Whisher 
Whisher
You tube filter + allowed tags trouble
March 08, 2010 03:28PM

Hi, I'm new at HP so be patience :) I don't see why this snippet don't get rid of the last div :(

function cleanComments($user_input_data)
{
  $purifier = new HTMLPurifier();
$purfier_config = HTMLPurifier_Config::createDefault();
$purfier_config->set('HTML.DefinitionID', 'User Content Filter');
$purfier_config->set('HTML.DefinitionRev', 1);
// these are allowed html tags, means white list
$purfier_config->set('HTML.Allowed', 'a,strong,em,p,span,img,li,ul,ol,sup,sub,small,big,code,blockquote,h1,h2,h3,h4,h5');
// these are allowed html attributes, coool!
$purfier_config->set('HTML.AllowedAttributes', 'a.href,a.title,span.style,span.class,span.id,p.style,img.src,img.style,img.alt,img.title,img.width,img.height');
// auto link given url string
$purfier_config->set('AutoFormat.Linkify', true);
// auto format \r\n lines
//$purfier_config->set('AutoFormat.AutoParagraph', true);
// clean empty tags
$purfier_config->set('AutoFormat.RemoveEmpty', true);
// cache dir, just for symfony of course, you can change to another path
//$purfier_config->set('Cache.SerializerPath', sfConfig::get('sf_cache_dir'));
// translation type, 
$purfier_config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
// allow youtube videos
$purfier_config->set('Filter.YouTube', true);
$purfier_config->set('HTML.TidyLevel', 'heavy');
// now clean your data
$cleanHtml = $purifier->purify($user_input_data, $purfier_config);
  return $cleanHtml;
}
$html = &#039;<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/BdU--T8rLns"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/BdU--T8rLns" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object><a>&#039;;
$html .= &#039; kkkk <a href="http://www.google.it/">pippo</a><p>pippo</p><em>ddd</em><div>pippo</div>&#039;; 
echo(cleanComments($html));

Bye

Re: You tube filter + allowed tags trouble
March 08, 2010 03:37PM
Sorry, you do not have permission to post/reply in this forum.