2

I'd like to use the Joomla default HTML tag/attribute blacklist for filtering some data coming into a custom API I have inside a Joomla component. The text at the bottom of the 'Text Filters' config page includes the following note:

-- Tags for the Default Blacklist include: 'applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml'

I've spent the last hour trawling through Joomla code trying to figure out where/when it creates an instance of JFilterInput that uses this default blacklist. Closest I can find is JComponentHelper, which seemingly does so within it's filterText() method, but it still isn't apparent to me where that default list is actually coming from (I couldn't even get JComponentHelper::filterText() to work for that matter).

Is there a handy way to get such a configured JFilterInput instance, or am I going to have to capture the blacklist tag set myself somewhere in my own component and pass this into JFilterInput::getInstance()?

1 Answer 1

1

I came back to this issue this evening and got to the bottom of it after opening my eyes a little wider. In essence, I need to do one of the following:

A) Configure a JInputFilter instance in blacklisting mode:

$filter = JInputFilter::getInstance([], [], 1, 1);

or

B) use JComponentHelper::filterText(), which will enforce the filtering rules configured in the 'Text Filters' page.

I posted a more detailed answer here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.