|
|
@@ -126,7 +126,7 @@ class Zend_Config_Yaml extends Zend_Config
|
|
|
*
|
|
|
* @param string $yaml YAML file to process
|
|
|
* @param mixed $section Section to process
|
|
|
- * @param array|boolean $options
|
|
|
+ * @param array|boolean $options
|
|
|
*/
|
|
|
public function __construct($yaml, $section = null, $options = false)
|
|
|
{
|
|
|
@@ -285,7 +285,7 @@ class Zend_Config_Yaml extends Zend_Config
|
|
|
$inIndent = false;
|
|
|
while (list($n, $line) = each($lines)) {
|
|
|
$lineno = $n + 1;
|
|
|
-
|
|
|
+
|
|
|
$line = rtrim(preg_replace("/#.*$/", "", $line));
|
|
|
if (strlen($line) == 0) {
|
|
|
continue;
|
|
|
@@ -314,16 +314,8 @@ class Zend_Config_Yaml extends Zend_Config
|
|
|
// key: value
|
|
|
if (strlen($m[2])) {
|
|
|
// simple key: value
|
|
|
- $value = rtrim(preg_replace("/#.*$/", "", $m[2]));
|
|
|
- // Check for booleans and constants
|
|
|
- if (preg_match('/^(t(rue)?|on|y(es)?)$/i', $value)) {
|
|
|
- $value = true;
|
|
|
- } elseif (preg_match('/^(f(alse)?|off|n(o)?)$/i', $value)) {
|
|
|
- $value = false;
|
|
|
- } elseif (!self::$_ignoreConstants) {
|
|
|
- // test for constants
|
|
|
- $value = self::_replaceConstants($value);
|
|
|
- }
|
|
|
+ $value = preg_replace("/#.*$/", "", $m[2]);
|
|
|
+ $value = self::_parseValue($value);
|
|
|
} else {
|
|
|
// key: and then values on new lines
|
|
|
$value = self::_decodeYaml($currentIndent + 1, $lines);
|
|
|
@@ -337,14 +329,8 @@ class Zend_Config_Yaml extends Zend_Config
|
|
|
// - FOO
|
|
|
if (strlen($line) > 2) {
|
|
|
$value = substr($line, 2);
|
|
|
- if (preg_match('/^(t(rue)?|on|y(es)?)$/i', $value)) {
|
|
|
- $value = true;
|
|
|
- } elseif (preg_match('/^(f(alse)?|off|n(o)?)$/i', $value)) {
|
|
|
- $value = false;
|
|
|
- } elseif (!self::$_ignoreConstants) {
|
|
|
- $value = self::_replaceConstants($value);
|
|
|
- }
|
|
|
- $config[] = $value;
|
|
|
+
|
|
|
+ $config[] = self::_parseValue($value);
|
|
|
} else {
|
|
|
$config[] = self::_decodeYaml($currentIndent + 1, $lines);
|
|
|
}
|
|
|
@@ -360,6 +346,38 @@ class Zend_Config_Yaml extends Zend_Config
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Parse values
|
|
|
+ *
|
|
|
+ * @param string $value
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ protected static function _parseValue($value)
|
|
|
+ {
|
|
|
+ $value = trim($value);
|
|
|
+
|
|
|
+ // remove quotes from string.
|
|
|
+ if ('"' == $value['0']) {
|
|
|
+ if ('"' == $value[count($value) -1]) {
|
|
|
+ $value = substr($value, 1, -1);
|
|
|
+ }
|
|
|
+ } elseif ('\'' == $value['0'] && '\'' == $value[count($value) -1]) {
|
|
|
+ $value = strtr($value, array("''" => "'", "'" => ''));
|
|
|
+ }
|
|
|
+
|
|
|
+ // Check for booleans and constants
|
|
|
+ if (preg_match('/^(t(rue)?|on|y(es)?)$/i', $value)) {
|
|
|
+ $value = true;
|
|
|
+ } elseif (preg_match('/^(f(alse)?|off|n(o)?)$/i', $value)) {
|
|
|
+ $value = false;
|
|
|
+ } elseif (!self::$_ignoreConstants) {
|
|
|
+ // test for constants
|
|
|
+ $value = self::_replaceConstants($value);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Replace any constants referenced in a string with their values
|
|
|
*
|
|
|
* @param string $value
|