According to the token_replace() function documentation, the $options array parameter can include:

clear: A boolean flag indicating that tokens should be removed from the final text if no replacement value can be generated.

However, there is nothing that actually does this.

echo token_replace('mystring/[invalid:token]', array(), array('clean' => TRUE));

Expected: mystring/
Actual: mystring/[invalid:token]

Comments

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new670 bytes
dave reid’s picture

StatusFileSize
new2.95 KB

With tests this time.

dave reid’s picture

#2: 681782-token-clean-D7.patch queued for re-testing.

dave reid’s picture

StatusFileSize
new2.58 KB

Re-rolled for HEAD.

dave reid’s picture

Issue tags: +pathauto

Tagging core issues that will help pathauto in core/D7.

mcarbone’s picture

Status: Needs review » Needs work

Looks good and works fine on my local install, although for clarity the message returned by the two assertFalse's (with 'clear' and without) should probably be different and not both "Basic placeholder tokens replaced." Also, I know that this patch doesn't introduce this, but it's weird that the second assertFalse with "Basic placeholder tokens replaced." appears below that comment block talking about the sanitization tests.

dave reid’s picture

Sanitization is different from the 'clear'. The former is making sure there's no XSS in tokens, the latter is making sure we get rid of invalid, non-replaceable tokens. I'll revise the inline comments shortly.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new3.57 KB

Revised in-line comments and test assertion messages. How's this one look mcarbone?

Status: Needs review » Needs work
Issue tags: -pathauto

The last submitted patch, 681782-token-clean-D7.patch, failed testing.

dave reid’s picture

Status: Needs work » Needs review

#8: 681782-token-clean-D7.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +pathauto

The last submitted patch, 681782-token-clean-D7.patch, failed testing.

dave reid’s picture

Status: Needs work » Needs review
mcarbone’s picture

Status: Needs review » Needs work

Fixes look good to me but patch doesn't apply cleanly:

patching file modules/system/system.test
Hunk #1 succeeded at 1449 (offset 41 lines).
Hunk #2 FAILED at 1670.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new3.22 KB

Here, give this a try.

mcarbone’s picture

Status: Needs review » Reviewed & tested by the community

Applies cleanly, works well, looks ready to go.

s3ndal3’s picture

Issue tags: -pathauto

#2: 681782-token-clean-D7.patch queued for re-testing.

s3ndal3’s picture

Issue tags: +pathauto

#1: 681782-token-clean-D7.patch queued for re-testing.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -pathauto

Automatically closed -- issue fixed for 2 weeks with no activity.