Issue #474424: Code doesn't verify the value entered by the user, and calls token_replace() with the wrong arguments included discussion of whether and how node information can be passed to filters.

Here's a very rough beginning of a patch. Missing parts are marked with // ....

Approach:
* Give token_filter a high weight to run after other nodeapi 'view' implementations.
* In nodeapi 'view', load iterate through each cck field as well as the body field
* For each cck field, determine the format, and determine if the format includes the token_filter filter.
* If it does, iterate through the values of the field and run the token filter on it, sending the fully built node as an arg.
* Rewrite the existing filter processing to use a cached node.

CommentFileSizeAuthor
token_filter_node_tokens.patch2.47 KBnedjo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pvhee’s picture

Any progress on this patch? I'd be willing to include it once it has been completed.

peterx’s picture

Will your weight change make the Token filter always run last of all the filters?

I notice the filter uses a high weight. There is an advantage to doing that in some of my modules and is an incentive to replace my custom code with Token Filter with this patch. Perhaps if I describe the use, you could mention how this patch fits.

In one of my sites a node body is copied into other bodies using a manual token substitution and I would like to do it via a standard token. The incoming node body is created with full HTML and goes into a node with full HTML. Currently I perform the substitution via a manual filter and give the filter a low weight to occur before the regular filters used in full HTML. This works but is hard to replicate across a lot of modules. It also means the substitution works only when both the source and target nodes are set to Full HTML.

Token filter with this patch appears to place the filter after the other filters. I think that means my incoming node body would be inserted without filtering. I would have to apply filtering to the source node body before passing the node body to the Token processing.

If I pass the incoming body through the filters manually and use this patch with the high weight, I would get the benefit of keeping the source node using Full HTML and be able to pass the body into a node that is set to Filtered HTML. This is a good thing. I could use Token Filter with this patch and gain the benefit of not needing Full HTML on the target nodes.

Is there an easy way to get the incoming node body filtered but not formatted so that it matches the target node at the point where Token Filter is applied? I am thinking of the following code and I think it will work if Token Filter with this patch always runs last. I think it will fail if there are filters that run after Token Filter because some of the content will be filtered twice.
check_markup($node->body, $node->format)

BenK’s picture

Subscribing...

Murz’s picture

Another solution for add node tokens: #730078: Replace CCK fields with token filter

darvanen’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 version is no longer supported. Please reopen this if you find it is relevant to Drupal 7 or 8.