Welcome! » Log In » Create A New Profile

Use HTMLPurifier to filter out everything but instagrm embed code

Posted by Sophie 
Use HTMLPurifier to filter out everything but instagrm embed code
April 11, 2017 06:06AM

I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.

I used HTMLPurifier in Laravel. I have been trying to configure HTMLPurifier to accept instagram embed code.

HTMLPurifier setting

return [ 'encoding' => 'UTF-8', 'finalize' => true, 'cachePath' => storage_path('app/purifier'), 'cacheFileMode' => 0755, 'settings' => [ 'default' => [ 'HTML.Doctype' => 'XHTML 1.0 Transitional', 'HTML.Allowed' => 'div,b,strong,p,i,em,blockquote[class|style],a[href|title],ul,ol,li,p[style],br,span[style],img[width|alt|src],iframe[src|width|height|class|frameborder]', 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align', 'HTML.AllowedAttributes' => 'style,src', 'AutoFormat.AutoParagraph' => true, 'AutoFormat.RemoveEmpty' => true, "HTML.SafeIframe" => true, "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/|api.soundcloud.com/tracks/)%", ], 'test' => [ 'Attr.EnableID' => true ] ],

After I using clean function on Instagram code,some of value of style attribute will be filter out. I have been trying to allow "style" in 'HTML.AllowedAttributes' setting.But it was not working.And tried to allowed css properties-'box-shadow'...etc,but some properties was not supported.

I want to keep all value of style attribute, and add some data attribute in HTMLPurifier.What can I do?

Thanks for your help !!

Re: Use HTMLPurifier to filter out everything but instagrm embed code
April 11, 2017 02:03PM

Maybe you can adapt the instructions at http://htmlpurifier.org/docs/enduser-youtube.html to apply to Instagram.

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with < and >.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: