Add context to system filters

Created on 17 May 2013, over 11 years ago
Updated 7 June 2023, over 1 year ago

The current filtering system is a global based filtering system such as filtering urls, converting \n to <p>, <br/> which is really good, but in doing some complex things such as quickly rendering some information from the current node is not always possible since there is no direct link between the text being filtered and the entity (node, comment, transaction etc) which is comes from.

One example of this is when using the PHP filter to build some text on node, to get the current node you need use the url, or the menu system to get the node object, which is fine on the when your url is node/xxx but when you are viewing a list of nodes, this is not possible.

This patch adds context to the current filtering system so that when you are filtering the text you also have access to the entity or any other variables that are relevant. So when rendering a text field, the filters will also have access to the node (if this field is on a node) directly.

This also opens the possibility to use less security problematic filters such as the PHP filter. Since Twig will be in core (fingers crossed), instead of using the PHP filter, we can use Twig to filter variables, and even control blocks and loops. Since Twig is all sandboxed, the ability to give access to a filter with much more control without the security implications.

Related Patches

#1996922: Twig Filter
Token Filter Needs work

Feature request
Status

Needs work

Version

11.0 🔥

Component
Filter 

Last updated 1 day ago

No maintainer
Created by

🇦🇺Australia gordon Melbourne

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France prudloff Lille

    In order to maintain backward compatibility, $context should be the last parameter in FilterInterface::process() and should be optional.

Production build 0.71.5 2024