ZF-6521: Zend_Config_Writer_Ini adds anti-slashes to strings

Issue Type: Bug Created: 2009-05-04T09:51:29.000+0000 Last Updated: 2009-12-17T17:52:25.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Aymeric le Gouvello (kaeran) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Config_Writer

Related issues: Attachments: - NoDoubleQuotes.patch


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.


Posted by Robert Basic (robertbasic) on 2009-11-19T11:56:55.000+0000

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.

Posted by Robert Basic (robertbasic) on 2009-11-19T12:37:53.000+0000

Attached the diff which should fix this.

Posted by Robert Basic (robertbasic) on 2009-11-19T12:51:16.000+0000

Attached the diff

Posted by Robert Basic (robertbasic) on 2009-11-19T13:10:47.000+0000

Reassigning to Ben so he can commit the patch.

Posted by Ken Chou (kenchou77) on 2009-11-26T00:49:02.000+0000

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..." }

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.