Download & Extend

'clean' option in token_replace() does not do anything

Project:Drupal core
Version:7.x-dev
Component:token system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:pathauto

Issue Summary

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.

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

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

Comments

#1

Status:active» needs review
AttachmentSizeStatusTest resultOperations
681782-token-clean-D7.patch670 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 18,706 pass(es).View details

#2

With tests this time.

AttachmentSizeStatusTest resultOperations
681782-token-clean-D7.patch2.95 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 681782-token-clean-D7_0.patch.View details

#3

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

#4

Re-rolled for HEAD.

AttachmentSizeStatusTest resultOperations
681782-token-clean-D7.patch2.58 KBIdlePASSED: [[SimpleTest]]: [MySQL] 17,898 pass(es).View details

#5

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

#6

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.

#7

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.

#8

Status:needs work» needs review

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

AttachmentSizeStatusTest resultOperations
681782-token-clean-D7.patch3.57 KBIdlePASSED: [[SimpleTest]]: [MySQL] 17,968 pass(es).View details

#9

Status:needs review» needs work

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

#10

Status:needs work» needs review

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

#11

Status:needs review» needs work

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

#12

Status:needs work» needs review

#13

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.

#14

Status:needs work» needs review

Here, give this a try.

AttachmentSizeStatusTest resultOperations
681782-token-clean-D7.patch3.22 KBIdlePASSED: [[SimpleTest]]: [MySQL] 18,678 pass(es).View details

#15

Status:needs review» reviewed & tested by the community

Applies cleanly, works well, looks ready to go.

#16

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

#17

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

#18

Status:reviewed & tested by the community» fixed

Committed to CVS HEAD. Thanks.

#19

Status:fixed» closed (fixed)

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