? core.kpf
? sites/default/files
? sites/default/settings.php
Index: includes/token.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/token.inc,v
retrieving revision 1.9
diff -u -p -r1.9 token.inc
--- includes/token.inc	12 Mar 2010 14:33:02 -0000	1.9
+++ includes/token.inc	25 Aug 2010 21:42:45 -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.140
diff -u -p -r1.140 system.test
--- modules/system/system.test	22 Aug 2010 14:55:29 -0000	1.140
+++ modules/system/system.test	25 Aug 2010 21:42:46 -0000
@@ -1566,6 +1566,47 @@ 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;
+    $url_options = array(
+      'absolute' => TRUE,
+      'language' => $language,
+    );
+
+    // Set a site variables for the token 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' => ']'),
+    );
+
+    // Run the test
+    // 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->assertFalse(strcmp($output, $expected), t('Token recognized in string %string', array('%string' => $input)));
+    }
+  }
+
+  /**
    * Tests the generation of all system date tokens.
    */
   function testSystemDateTokenReplacement() {
