Commit 28f8c5e8 authored by webchick's avatar webchick
Browse files

#424372 by mr.baileys: Fix ':: in .info files causes fatal error' bug.

parent f546cfa1
......@@ -5944,6 +5944,7 @@ function drupal_parse_info_file($filename) {
*/
function drupal_parse_info_format($data) {
$info = array();
$constants = get_defined_constants();
if (preg_match_all('
@^\s* # Start at the beginning of a line, ignoring leading whitespace
......@@ -5982,8 +5983,8 @@ function drupal_parse_info_format($data) {
$parent = &$parent[$key];
}
// Handle PHP constants
if (defined($value)) {
// Handle PHP constants.
if (isset($constants[$value])) {
$value = constant($value);
}
......
......@@ -1575,6 +1575,29 @@ class DrupalErrorCollectionUnitTest extends DrupalWebTestCase {
}
}
/**
* Test the drupal_parse_info_file() API function.
*/
class ParseInfoFilesTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Parsing .info files',
'description' => 'Tests parsing .info files.',
'group' => 'System',
);
}
/**
* Parse an example .info file an verify the results.
*/
function testParseInfoFile() {
$info_values = drupal_parse_info_file(drupal_get_path('module', 'simpletest') . '/tests/common_test_info.txt');
$this->assertEqual($info_values['simple_string'], 'A simple string', t('Simple string value was parsed correctly.'), t('System'));
$this->assertEqual($info_values['simple_constant'], WATCHDOG_INFO, t('Constant value was parsed correctly.'), t('System'));
$this->assertEqual($info_values['double_colon'], 'dummyClassName::', t('Value containing double-colon was parsed correctly.'), t('System'));
}
}
/**
* Tests for the format_date() function.
*/
......
; $Id$
; Test parsing with a simple string.
simple_string = A simple string
; Test that constants can be used as values.
simple_constant = WATCHDOG_INFO
; After parsing the .info file, 'double_colon' should hold the literal value.
; Parsing should not throw a fatal error or try to access a class constant.
double_colon = dummyClassName::
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment