Closed metaturso closed 5 years ago
Yeah, your problem is that you're not adding the filter to HTML Purifier correctly. The docs do actually say how to do it correctly:
$uri = $config->getDefinition('URI');
$uri->addFilter(new HTMLPurifier_URIFilter_<strong>NameOfFilter</strong>(), $config);</pre>
To answer your questions directly:
Thank for your reply.
How would you feel about losing the need for extension classes to comply with a naming scheme? I bet many people like myself find this requirement fairly irritating when attemtping to integrate HTMLPurifier in a namespaced PHP codebase.
I'd accept a patch on that, but I'm not exactly sure what a clean way to go about doing it is.
Affected version and environment
The problem: Trying to register a URI filter with the following code fails. Could be a bug, a documentation problem, or PEBKAC. I'm seeking clarification.
The error message:
From this document I understand one must extend the class
HTMLPurifier_URIFilter
. It's unclear if the name of this subclass MUST be prefixed byHTMLPurifier_URIFilter_
or whetherNameOfFilter
MAY just suffice.Secondly, by looking at the control and data flow in
HTMLPurifier::purify()
it doesn't look like there's any type checking around filters.In my case this has been causing my subclass of
HTMLPurifier_URIFilter
-- whose interface lacks bothpreFilter
andpostFilter
-- to trigger an error because the polymorphic filter logic ends up calling a non-existing method on some object.From
HTMLPurifier::purify
with my own comments.Based on the above I need some help to understand what went wrong here, and decide what steps I can take next to work around this problem.
HTMLPurifier::purify()
code to check types and not to rely excessively on polymorphic behaviour, orHTMLPurifier_URIFilter
subclassHTMLPurifier_Filter
perhaps, or