Index: library/Zend/Config/Yaml.php =================================================================== --- library/Zend/Config/Yaml.php (revision 24580) +++ library/Zend/Config/Yaml.php (working copy) @@ -126,7 +126,7 @@ * * @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 @@ $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 @@ // 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 @@ // - 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 @@ } /** + * 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 Index: tests/Zend/Config/_files/array.yaml =================================================================== --- tests/Zend/Config/_files/array.yaml (revision 24580) +++ tests/Zend/Config/_files/array.yaml (working copy) @@ -20,3 +20,6 @@ - eight: 3 nine: 3 +fourteen: + fifteen: '1'41''5' + sixteen: "1416" Index: tests/Zend/Config/YamlTest.php =================================================================== --- tests/Zend/Config/YamlTest.php (revision 24580) +++ tests/Zend/Config/YamlTest.php (working copy) @@ -319,7 +319,7 @@ $this->assertEquals('ZEND_CONFIG_YAML_ENV', $config->env); $this->assertEquals('ZEND_CONFIG_YAML_ENV_PATH/test/this', $config->path); } - + /** * @group ZF-11329 */ @@ -329,7 +329,7 @@ $this->assertType('Zend_Config', $config->resources); $this->assertType('Zend_Config', $config->resources->frontController); $this->assertType( - 'string', + 'string', $config->resources->frontController->controllerDirectory ); $this->assertSame( @@ -337,7 +337,7 @@ $config->resources->frontController->controllerDirectory ); } - + /** * @group ZF-11384 */ @@ -347,7 +347,7 @@ $this->assertType('Zend_Config', $config->resources); $this->assertType('Zend_Config', $config->resources->frontController); $this->assertType( - 'string', + 'string', $config->resources->frontController->controllerDirectory ); $this->assertSame( @@ -355,7 +355,7 @@ $config->resources->frontController->controllerDirectory ); } - + /** * @group ZF-11702 */ @@ -363,13 +363,13 @@ { if (!defined('ZEND_CONFIG_YAML_TEST_PATH')) { define('ZEND_CONFIG_YAML_TEST_PATH', 'testing'); - } + } $config = new Zend_Config_Yaml($this->_yamlListConstantsConfig, 'production'); $this->assertEquals(ZEND_CONFIG_YAML_TEST_PATH, $config->paths->{0}); $this->assertEquals(ZEND_CONFIG_YAML_TEST_PATH . '/library/test', $config->paths->{1}); } - + /** * @group ZF-11702 */ @@ -405,5 +405,15 @@ $this->assertFalse($config->usingTitleCasedOff->{0}); $this->assertFalse($config->usingCapitalOff->{0}); } - + + /** + * @group ZF-11363 + */ + public function testStripQuotesInLists() + { + $config = new Zend_Config_Yaml($this->_iniFileSameNameKeysConfig, null); + $this->assertEquals('141\'5', $config->fourteen->fifteen); + + $this->assertEquals('1416', $config->fourteen->sixteen); + } }