Skip to content

Commit

Permalink
Fix #11166: Complex types could not be entered with newline chars
Browse files Browse the repository at this point in the history
When setting complex configuration values via Manage Configuration =>
Configuration Report, newline characters weren't parsed correctly. This
meant that users had to enter complex array types on a single line.

This patch resolves the issue by stripping newline characters from any
complex type entered. It also applies a few other fixes to the parsing
of complex array types.

Bugs do remain and this complex array parsing is still very limited. The
current problems are:
* An inability to parse multidimensional arrays
* Array keys and values cannot contain commas or "=>"
  • Loading branch information
davidhicks committed Apr 23, 2010
1 parent d793dbd commit 4dd383f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions adm_config_set.php
Expand Up @@ -99,20 +99,24 @@
# 1. constant values (like the ON/OFF switches): they are defined as constants mapping to numeric values
# 2. simple arrays with the form: array( a, b, c, d )
# 3. associative arrays with the form: array( a=>1, b=>2, c=>3, d=>4 )
# TODO: allow multi-dimensional arrays, allow commas and => within strings
$t_full_string = trim( $f_value );
if ( preg_match('/array[\s]*\((.*)\)/', $t_full_string, $t_match ) === 1 ) {
if ( preg_match('/array[\s]*\((.*)\)/s', $t_full_string, $t_match ) === 1 ) {
// we have an array here
$t_values = explode( ',', trim( $t_match[1] ) );
foreach ( $t_values as $key => $value ) {
if ( !trim( $value ) ) {
continue;
}
$t_split = explode( '=>', $value, 2 );
if ( count( $t_split ) == 2 ) {
// associative array
$t_new_key = constant_replace( trim( $t_split[0] ) );
$t_new_value = constant_replace( trim( $t_split[1] ) );
$t_new_key = constant_replace( trim( $t_split[0], " \t\n\r\0\x0B\"'" ) );
$t_new_value = constant_replace( trim( $t_split[1], " \t\n\r\0\x0B\"'" ) );
$t_value[ $t_new_key ] = $t_new_value;
} else {
// regular array
$t_value[ $key ] = constant_replace( trim( $value ) );
$t_value[ $key ] = constant_replace( trim( $value, " \t\n\r\0\x0B\"'" ) );
}
}
} else {
Expand Down

0 comments on commit 4dd383f

Please sign in to comment.