File "SafeForms.php"

Full Path: /home/spiraleeea/www/spirale/plugins-dist/safehtml/lib/xemlock/htmlpurifier-html5/library/HTMLPurifier/HTMLModule/HTML5/SafeForms.php
File size: 1.66 KB
MIME-type: text/x-php
Charset: utf-8

<?php


/**
 * Safe HTML5 form elements
 */
class HTMLPurifier_HTMLModule_HTML5_SafeForms extends HTMLPurifier_HTMLModule
{
    public $name = 'HTML5_SafeForms';

    public $safe = true;

    /**
     * @param HTMLPurifier_Config $config
     */
    public function setup($config)
    {
        $this->addElement(
            'fieldset',
            'Form',
            new HTMLPurifier_ChildDef_HTML5_Fieldset(),
            'Common',
            array(
                'name' => 'CDATA',
                'disabled' => 'Bool#disabled',
                // 'form' => 'IDREF', // IDREF not implemented, potentially unsafe, cannot allow
            )
        );

        // https://html.spec.whatwg.org/dev/form-elements.html#the-legend-element
        // Content model: Phrasing content, optionally intermixed with heading content.
        $this->addElement(
            'legend',
            false,
            'Optional: #PCDATA | Inline | Heading',
            'Common',
            array(
                'accesskey' => 'Character',
            )
        );

        // https://html.spec.whatwg.org/dev/form-elements.html#the-progress-element
        $progress = $this->addElement(
            'progress',
            'Flow',
            'Inline',
            'Common',
            array(
                'value' => new HTMLPurifier_AttrDef_HTML5_Float(array('min' => 0)),
                'max' => new HTMLPurifier_AttrDef_HTML5_Float(array('min' => 0)),
            )
        );
        $progress->excludes = array('progress' => true);
        $this->addElementToContentSet('progress', 'Inline');

        $progress->attr_transform_post[] = new HTMLPurifier_AttrTransform_HTML5_Progress();
    }
}