ZF-6521: Zend_Config_Writer_Ini adds anti-slashes to strings


Zend_Config_Writer_Ini adds anti-slashes to strings when it writes data into files the same as does Zend_Config_Writer_Array. but it encloses the string in " " quotes.

Once you read the file, strings remain escaped with anti-slashes and you have to parse your Zend_Config object.

Workaround : in Zend_Config_Writer_Ini function's _prepareValue(), don't parse strings with addslashes().

Hope report correct and appropriate. its my first.


When reading an .ini file with parse_ini_file(), all double quotes - escaped or not - are removed: so str"ing becomes string and str\"ing becomes str\ing.

Talked with Ben about this, removing the addslashes() and throwing an Exception when a double quote is inside the stored value.

Attached the diff which should fix this.

Attached the diff

Reassigning to Ben so he can commit the patch.

double quotes in value may cause .ini file incorrect.

--- reproduct code: ---

require_once 'Zend/Config/Writer/Ini.php'; require_once 'Zend/Config/Ini.php';

$data = array( 'testKey' => 'test"quotes', 'nextKey' => 'blah,blah,blah...', ); $file = 'test.ini';

$config = new Zend_Config($data); // write $options = array('config' => $config , 'filename' => $file); $writer = new Zend_Config_Writer_Ini($options); $writer->write();

// read $config = new Zend_Config_Ini($file); var_dump($config->toArray());

--- expect result --- array(2) { ["testKey"]=> string(10) "testquotes" ["nextKey"]=> string(17) "blah,blah,blah..." }

--- actual result --- array(1) { ["testKey"]=> string(39) "test\quotes nextKey = blah,blah,blah..." }