Skip to content

The definition is ignored in case of HTMLPurifier_Config::inherit() usage #16

@xgrn

Description

@xgrn

Hi.

Thanks for the great library which saves developer lifetime 😄

I'm using this config to override the Purifier configuration in a Symfony project with the exercise/htmlpurifier-bundle

The bundle creates the parent configuration than uses HTMLPurifier_Config::inherit() method to create the child one. The method implementation is taken from the parent class, not HTML5Config as the following.

    /**
     * Creates a new config object that inherits from a previous one.
     * @param HTMLPurifier_Config $config Configuration object to inherit from.
     * @return HTMLPurifier_Config object with $config as its parent.
     */
    public static function inherit(HTMLPurifier_Config $config)
    {
        return new HTMLPurifier_Config($config->def, $config->plist);
    }

As a result all the child configurations are HTMLPurifier_Config instances instead of HTMLPurifier_HTML5Config which causes errors as they don't support HTML5 tags.

I'm using a workaround inheriting the base class like:

class HTMLPurifier_AltHTML5Config extends \HTMLPurifier_HTML5Config
{
    public static function inherit(HTMLPurifier_Config $config)
    {
        return new static($config->def, $config->plist);
    }
}

But the 'inherit()' method should be overridden as well, I suppose.

Thanks again.
Best wishes.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions