ZF-12278: Zend_Config_Yaml comment hash bug


The fix in the above ticket allows for in-line comments at the end of the value but causes a bug that prevents values with legitimate hash characters such as passwords from being read properly. Encasing the value within double or single quotes did not resolve the problem wither.

I did alter a couple of regex strings in "Zend/Config/Yaml.php" that appears to have resolved it.

@ Line 289:
            // New
            $line = rtrim(preg_replace("/^#.*$/", "", $line));

            // Old
            $line = rtrim(preg_replace("/#.*$/", "", $line));

@ Line 317: 
            // New simple key: value
            $value = rtrim( preg_replace( "/(.*)(\s+#.*?)$/", "\\1", $m[2] ) );

            // Old simple key: value
            $value = rtrim(preg_replace("/#.*$/", "", $m[2]));

This update appears to allow a hash at the beginning of the line to comment the entire line, a hash at the end of the value for an in-line comment and to allow for a hash to remain in the value when using hashes in passwords or anything else someone may want/need.


No comments to display