? .komodotools ? README.txt ? core.komodoproject ? core.kpf ? sites/default/settings.php Index: includes/token.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/token.inc,v retrieving revision 1.10 diff -u -p -r1.10 token.inc --- includes/token.inc 18 Oct 2010 01:13:07 -0000 1.10 +++ includes/token.inc 11 Dec 2010 11:53:54 -0000 @@ -106,7 +106,7 @@ function token_replace($text, array $dat function token_scan($text) { // Matches tokens with the following pattern: [$type:$token] // $type and $token may not contain white spaces. - preg_match_all('/\[([^\s\]:]*):([^\s\]]*)\]/', $text, $matches); + preg_match_all('/\[([^\s\[\]:]*):([^\s\[\]]*)\]/', $text, $matches); $types = $matches[1]; $tokens = $matches[2]; Index: modules/system/system.test =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.test,v retrieving revision 1.153 diff -u -p -r1.153 system.test --- modules/system/system.test 1 Dec 2010 00:23:36 -0000 1.153 +++ modules/system/system.test 11 Dec 2010 11:53:55 -0000 @@ -1634,6 +1634,42 @@ class TokenReplaceTestCase extends Drupa } /** + * Test to see if tokens are recognized when contained in a string. + * + * We check if valid tokens are recognized as part of a text environment. + * We add various strings as prefix and suffix and assert if the token is + * replaced correctly. + */ + function testSystemTokenRecognition() { + global $language; + + // Set a site variable for Token to work with. + variable_set('site_name', 'Drupal'); + + // Generate token prefixes and suffixes. + $tests = array( + array('prefix' => 'this is the ', 'suffix' => ' site'), + array('prefix' => 'this is the', 'suffix' => 'site'), + array('prefix' => '[', 'suffix' => ']'), + array('prefix' => '', 'suffix' => ']]]'), + array('prefix' => '[[[', 'suffix' => ''), + array('prefix' => ':[:', 'suffix' => '--]'), + array('prefix' => '-[-', 'suffix' => ':]:'), + array('prefix' => '[:', 'suffix' => ']'), + array('prefix' => '[site:', 'suffix' => ':name]'), + array('prefix' => '[site:', 'suffix' => ']'), + ); + + // Prefixes and suffixes are added to both the token and the expected return value. + foreach ($tests as $test) { + $input = $test['prefix'] . '[site:name]' . $test['suffix']; + $expected = $test['prefix'] . 'Drupal' . $test['suffix']; + $output = token_replace($input, array(), array('language' => $language)); + $this->assertTrue($output == $expected, t('Token recognized in string %string', array('%string' => $input))); + } + } + + /** * Tests the generation of all system date tokens. */ function testSystemDateTokenReplacement() {