Index: includes/registry.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/registry.inc,v
retrieving revision 1.15
diff -u -9 -p -r1.15 registry.inc
--- includes/registry.inc	10 May 2009 16:46:23 -0000	1.15
+++ includes/registry.inc	13 May 2009 17:43:33 -0000
@@ -256,16 +256,22 @@ function _registry_skip_body(&$tokens) {
   while ($num_braces && ($token = next($tokens))) {
     // PHP is really logical to have three different tokens for { with
     // inconsistent names and only one for a closing brace.
     if ($token == '{' || (is_array($token) && ($token[0] == T_DOLLAR_OPEN_CURLY_BRACES || $token[0] == T_CURLY_OPEN))) {
       ++$num_braces;
     }
     elseif ($token == '}') {
       --$num_braces;
     }
+    // Consume strings manually as workaround for a bug in PHP < 5.2.3 (see
+    // http://drupal.org/node/368116).
+    elseif ($token == '"' || $token == '`' || (is_array($token) && $token[0] == T_START_HEREDOC)) {
+      $stop = is_array($token) ? T_END_HEREDOC : $token;
+      while (($token = next($tokens)) && (is_array($token) ? $token[0] : $token) != $stop);
+    }
   }
 }
 
 /**
  * @} End of "defgroup registry".
  */
 
Index: modules/simpletest/tests/registry.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/registry.test,v
retrieving revision 1.7
diff -u -9 -p -r1.7 registry.test
--- modules/simpletest/tests/registry.test	10 May 2009 16:46:24 -0000	1.7
+++ modules/simpletest/tests/registry.test	13 May 2009 17:43:33 -0000
@@ -140,18 +140,26 @@ class RegistrySkipBodyTestCase extends D
     return array(
       'name' => t('Skip function body test'),
       'description' => t('Tokenize a simple function and check that the body is skipped right'),
       'group' => t('System'),
     );
   }
   
   function testRegistrySkipBody () {
     // This string contains all three kinds of opening braces.
-    $function = '<?php function foo () { $x = "{$y}"; $x = "${y}" }';
+    $function = '<?php function foo () { $x = "{$y}"; $x = "${y}"; }';
     $tokens = token_get_all($function);
     _registry_skip_body($tokens);
     // Consume the last }
     each($tokens);
     $this->assertIdentical(each($tokens), FALSE, t('Tokens skipped'));
+
+    // Check workaround for PHP < 5.2.3 regarding tokenization of strings
+    // containing variables. The { contained in the string should not be
+    // treated as a separate token.
+    $function = '<?php function foo() { $x = "$y {"; $x = `$y {`; $x = ' . "<<<EOD\n\$y {\nEOD\n; } function bar() {}";
+    $tokens = token_get_all($function);
+    _registry_skip_body($tokens);
+    $this->assertTrue(each($tokens), t('Tokens not skipped to end of file.'));
   }
 
-}
\ No newline at end of file
+}
