|
SafeIframe not working for me February 23, 2012 03:08PM |
Registered: 1 year ago Posts: 3 |
Hi,
Thanks for HTMLPurifier!
I've been trying to get iframes to go through but haven't been successful. Here's a snippet of the code:
$CI =& CI_Base::get_instance();
$CI->load->library('HTMLPurifier');
$oConfig = HTMLPurifier_Config::createDefault();
$oConfig->set('Cache', 'SerializerPath', rtrim($CI->config->item('cache_path'), "/"));
$oConfig->set('HTML', 'DefinitionRev', 3); // Increment this number if you change any configs so that the cache is refreshed
$oConfig->set('HTML.SafeIframe', true);
/* $oConfig->set('URI.IframeWhitelistRegexp', array(
'/^https?:\/\/www\.youtube\.com\/embed\/[a-zA-Z0-9]+$/',
'/^https?:\/\/player\.vimeo\.com\/video\/[0-9]+$/'
));*/
$oConfig->set('URI.IframeWhitelistRegexp', array('%%'));
I incremented DefinitionRev as instructed. I'm loading it with CodeIgniter. And you can see my commented-out attempt at a whitelist.
Thanks so much for any help!
|
Re: SafeIframe not working for me February 23, 2012 03:45PM |
Admin Registered: 6 years ago Posts: 2,640 |
|
Re: SafeIframe not working for me February 23, 2012 05:45PM |
Registered: 1 year ago Posts: 3 |
Thanks for your reply.
I have the following now:
$CI =& CI_Base::get_instance();
$CI->load->library('HTMLPurifier');
$oConfig = HTMLPurifier_Config::createDefault();
$oConfig->set('Cache', 'SerializerPath', rtrim($CI->config->item('cache_path'), "/"));
// $oConfig->set('HTML', 'DefinitionRev', 3); // Increment this number if you change any configs so that the cache is refreshed
$oConfig->set('HTML.SafeIframe', true);
$oConfig->set('URI.IframeWhitelistRegexp', array(
'/^https?:\/\/www\.youtube\.com\/embed\/[a-zA-Z0-9]+$/',
'/^https?:\/\/player\.vimeo\.com\/video\/[0-9]+$/'
));
but it still strips out an iframe from Vimeo.
Any help most appreciated.
|
Re: SafeIframe not working for me February 23, 2012 05:47PM |
Admin Registered: 6 years ago Posts: 2,640 |
|
Re: SafeIframe not working for me February 23, 2012 05:53PM |
Registered: 1 year ago Posts: 3 |
Thanks for the reply!
I tried this:
$oConfig->set('HTML.SafeIframe', true);
$oConfig->set('URI.IframeWhitelistRegexp', '/^https?:\/\/player\.vimeo\.com\/video\/[0-9]+.*$/');
I'm trying to match:
<iframe src="http://player.vimeo.com/video/20452240?title=0&byline=0&portrait=0&color=ffffff" width="640" height="424" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
Still it's getting removed.
|
Re: SafeIframe not working for me February 23, 2012 05:57PM |
Admin Registered: 6 years ago Posts: 2,640 |
|
Brett W. Thompson
Re: SafeIframe not working for meFebruary 25, 2012 12:05PM |
|
Re: SafeIframe not working for me February 25, 2012 12:34PM |
Admin Registered: 6 years ago Posts: 2,640 |