Use Filters for the Token content rather than asking users to write PHP.

Comments

robloach’s picture

Title: Add Token Input replacement alongside PHP Input replacement » Use Filters for Custom Tokens rather than PHP
Status: Active » Needs review
StatusFileSize
new43.65 KB
new6.52 KB

Exposing PHP to the end user is definitely not a good idea. This patch makes it use filters instead. The upgrade path is supported.

robloach’s picture

Issue summary: View changes

Updated issue summary.

dave reid’s picture

How does this work if $options['sanitize'] = FALSE is provided from token_replace()?

dave reid’s picture

Aside from #2, I think this is a *great* change. Easily allows 'simple' tokens while also allowing the complex PHP tokens.

gaspaio’s picture

Ok thanks. This change was actually on my short term roadmap, i totally agree with the fact that a default PHP field is a nono.
I'll check your patch over the weekend ; i'm curious to see how you pass the $data array to the filter when php filter is on.
Thanks.

gaspaio’s picture

StatusFileSize
new7.95 KB

Added a few changes to your patch : the $data and $options arrays are now available to the evaluated php code (if php filter is used). It should solve #2 and keep the current features.

gaspaio’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev

Just commited latest patch to the newly created dev release.
The issue remains open for a while since this still needs some testing.
Thanks.

gaspaio’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Since this is a major change, that might not please all of the module's users, this patch was moved to the a new version branch - 7.x-2.x (it should be visible in a few hours).

Version 7.x-1.x will keep the old PHP-only approach and receive bug fixes only.

gaspaio’s picture

Status: Needs review » Closed (fixed)
gaspaio’s picture

Issue summary: View changes

Updated issue summary.