Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
28f8c5e8
Commit
28f8c5e8
authored
Nov 11, 2009
by
Angie Byron
Browse files
#424372
by mr.baileys: Fix ':: in .info files causes fatal error' bug.
parent
f546cfa1
Changes
3
Hide whitespace changes
Inline
Side-by-side
includes/common.inc
View file @
28f8c5e8
...
...
@@ -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
);
}
...
...
modules/simpletest/tests/common.test
View file @
28f8c5e8
...
...
@@ -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.
*/
...
...
modules/simpletest/tests/common_test_info.txt
0 → 100644
View file @
28f8c5e8
; $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::
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment