Welcome! » Log In » Create A New Profile

The HTML5 element <vedio> is filtered out when I using htmlpurifer

Posted by 287586894 
The HTML5 element <vedio> is filtered out when I using htmlpurifer
June 06, 2014 10:36AM

The HTML5 element is filtered out when I using htmlpurifer , I really don't want it to be filtered out,

The following is my original code:

<p>

    <video class="edui-upload-video  vjs-default-skin video-js" controls="" preload="none" width="420" height="420" src="/Uploads/UEditor/video/20140606/1402063070123927.wav" data-setup="{}">

        <source src="/Uploads/UEditor/video/20140606/1402063070123927.wav" type="video/wav"/>

    </video>

</p>

I want to make this code will not be filtered !

who know? i am from china ! english is poor! if you can know my Chinese English!

Tell me the soluation! thanks !!

Re: The HTML5 element <vedio> is filtered out when I using htmlpurifer
June 06, 2014 09:56PM

Unfortunately HTML Purifier does not support the video element at this moment.

Re: The HTML5 element <vedio> is filtered out when I using htmlpurifer
June 07, 2014 07:47AM

I have found the code about Support html5 ! It basically solves the problems I meet now!


$config = HTMLPurifier_Config::createDefault();
 
  //html5标签
  $config->set(&#039;HTML.Doctype&#039;, &#039;HTML 4.01 Transitional&#039;);
  $config->set(&#039;CSS.AllowTricky&#039;, true);
  $config->set(&#039;Cache.SerializerPath&#039;, &#039;/tmp&#039;);
  //embed标签
  $config->set(&#039;HTML.SafeEmbed&#039;,true);
  $config->set(&#039;HTML.SafeObject&#039;,true);
  // Allow iframes from:
  // o YouTube.com
  // o Vimeo.com
  $config->set(&#039;HTML.SafeIframe&#039;, true);
  $config->set(&#039;URI.SafeIframeRegexp&#039;, &#039;%^(http:|https:)?//(www.youtube(?:-nocookie)?.com/embed/|player.vimeo.com/video/)%&#039;);
  $config->set(&#039;HTML.Allowed&#039;, implode(&#039;,&#039;, $allowed));
  // Set some HTML5 properties
  $config->set(&#039;HTML.DefinitionID&#039;, &#039;html5-definitions&#039;); // unqiue id
  $config->set(&#039;HTML.DefinitionRev&#039;, 1);

  if ($def = $config->maybeGetRawHTMLDefinition()) {
    // http://developers.whatwg.org/sections.html
    $def->addElement(&#039;section&#039;, &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;);
    $def->addElement(&#039;nav&#039;,     &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;);
    $def->addElement(&#039;article&#039;, &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;);
    $def->addElement(&#039;aside&#039;,   &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;);
    $def->addElement(&#039;header&#039;,  &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;);
    $def->addElement(&#039;footer&#039;,  &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;);

    // Content model actually excludes several tags, not modelled here
    $def->addElement(&#039;address&#039;, &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;);
    $def->addElement(&#039;hgroup&#039;, &#039;Block&#039;, &#039;Required: h1 | h2 | h3 | h4 | h5 | h6&#039;, &#039;Common&#039;);

    // http://developers.whatwg.org/grouping-content.html
    $def->addElement(&#039;figure&#039;, &#039;Block&#039;, &#039;Optional: (figcaption, Flow) | (Flow, figcaption) | Flow&#039;, &#039;Common&#039;);
    $def->addElement(&#039;figcaption&#039;, &#039;Inline&#039;, &#039;Flow&#039;, &#039;Common&#039;);

    // http://developers.whatwg.org/the-video-element.html#the-video-element
    $def->addElement(&#039;video&#039;, &#039;Block&#039;, &#039;Optional: (source, Flow) | (Flow, source) | Flow&#039;, &#039;Common&#039;, array(
      &#039;src&#039; => &#039;URI&#039;,
      &#039;type&#039; => &#039;Text&#039;,
      &#039;width&#039; => &#039;Length&#039;,
      &#039;height&#039; => &#039;Length&#039;,
      &#039;poster&#039; => &#039;URI&#039;,
      &#039;preload&#039; => &#039;Enum#auto,metadata,none&#039;,
      &#039;controls&#039; => &#039;Bool&#039;,
    ));
    $def->addElement(&#039;source&#039;, &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;, array(
      &#039;src&#039; => &#039;URI&#039;,
      &#039;type&#039; => &#039;Text&#039;,
    ));

    // http://developers.whatwg.org/text-level-semantics.html
    $def->addElement(&#039;s&#039;,    &#039;Inline&#039;, &#039;Inline&#039;, &#039;Common&#039;);
    $def->addElement(&#039;var&#039;,  &#039;Inline&#039;, &#039;Inline&#039;, &#039;Common&#039;);
    $def->addElement(&#039;sub&#039;,  &#039;Inline&#039;, &#039;Inline&#039;, &#039;Common&#039;);
    $def->addElement(&#039;sup&#039;,  &#039;Inline&#039;, &#039;Inline&#039;, &#039;Common&#039;);
    $def->addElement(&#039;mark&#039;, &#039;Inline&#039;, &#039;Inline&#039;, &#039;Common&#039;);
    $def->addElement(&#039;wbr&#039;,  &#039;Inline&#039;, &#039;Empty&#039;, &#039;Core&#039;);

    // http://developers.whatwg.org/edits.html
    $def->addElement(&#039;ins&#039;, &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;, array(&#039;cite&#039; => &#039;URI&#039;, &#039;datetime&#039; => &#039;CDATA&#039;));
    $def->addElement(&#039;del&#039;, &#039;Block&#039;, &#039;Flow&#039;, &#039;Common&#039;, array(&#039;cite&#039; => &#039;URI&#039;, &#039;datetime&#039; => &#039;CDATA&#039;));

    // TinyMCE
    $def->addAttribute(&#039;img&#039;, &#039;data-mce-src&#039;, &#039;Text&#039;);
    $def->addAttribute(&#039;img&#039;, &#039;data-mce-json&#039;, &#039;Text&#039;);

    // Others
    $def->addAttribute(&#039;iframe&#039;, &#039;allowfullscreen&#039;, &#039;Bool&#039;);
    $def->addAttribute(&#039;table&#039;, &#039;height&#039;, &#039;Text&#039;);
    $def->addAttribute(&#039;td&#039;, &#039;border&#039;, &#039;Text&#039;);
    $def->addAttribute(&#039;th&#039;, &#039;border&#039;, &#039;Text&#039;);
    $def->addAttribute(&#039;tr&#039;, &#039;width&#039;, &#039;Text&#039;);
    $def->addAttribute(&#039;tr&#039;, &#039;height&#039;, &#039;Text&#039;);
    $def->addAttribute(&#039;tr&#039;, &#039;border&#039;, &#039;Text&#039;);
  }
  
 
Re: The HTML5 element <vedio> is filtered out when I using htmlpurifer
April 03, 2016 04:37AM

The sizegenetics testimonials are up now.

Unfortunately HTML Purifier does not support the video element at this moment.

Does HTML Purifier support video these days?

Edited 1 time(s). Last edit at 12/19/2016 03:51AM by Devro.

Re: The HTML5 element <vedio> is filtered out when I using htmlpurifer
April 05, 2016 07:06PM

Nope, but maybe the code above should be helpful for you.

Sorry, you do not have permission to post/reply in this forum.