#5993: Configure::store() shouldn't save everything as a string, and shouldn't 
add
slashes to double quotes
-------------------------------------------+--------------------------------
    Reporter:  zackenbarsch                |          Type:  Bug      
      Status:  new                         |      Priority:  Medium   
   Milestone:  1.2.x.x                     |     Component:  Core Libs
     Version:  1.2 Final                   |      Severity:  Normal   
    Keywords:  configure,store,type,slash  |   Php_version:  PHP 5    
Cake_version:  1.2.0.7962                  |  
-------------------------------------------+--------------------------------
 Configure::store() shouldn't save everything as a string, and shouldn't
 add slashes to double quotes

 When using Configure::store() to write a config file all values are stored
 as strings, this can led to problems with strict comparisions. The example
 from the function comment

 {{{
 #!php
 Configure::store('Model', 'class.paths', array('Users' => array( 'path' =>
 'users', 'plugin' => true)));
 }}}

 generates the following code

 {{{
 #!php
 $config = array();
 $config['Model']['Users'] = array('path' => 'users', 'plugin' => '1', );
 }}}

 and so the following comparision will fail

 {{{
 #!php
 $config['Model']['Users']['plugin'] === true
 }}}

 [[BR]]
 Another problem are the slashes, they are added no matter what the value
 looks like, and so when using double quotes in a value you'll end up with
 slashes that tamper the value.
 {{{
 #!php
 Configure::store('Test', 'test', array('key' => '"value"'));
 }}}
 ends up as
 {{{
 #!php
 $config['Test']['key'] = '\"value\"';
 }}}

 and so the following comparision will fail

 {{{
 #!php
 $config['Test']['key'] === '"value"'
 }}}

 [[BR]][[BR]]

 Here are two tests for the problem
 {{{
 #!php
 $expected = array('data' => 'some "value\\" with \' quotes...');
 Configure::store('QuoteExample', 'test.quote', $expected);

 Configure::load('test.quote');
 $config = Configure::read('QuoteExample');
 $this->assertEqual($config, $expected);

 $expected = array('data' => array('number' => 10, 'boolean' => true,
 'string' => 'value', 'null' => null));
 Configure::store('TypeExample', 'test.type', $expected);

 Configure::load('test.type');
 $config = Configure::read('TypeExample');
 $this->assertIdentical($config, $expected);
 }}}

 [[BR]]
 Also attached a potential patch that fixes the problems, but i'm note sure
 if it's really neccessary to quote the null byte...

 [[BR]][[BR]]
 Regards[[BR]]
 Frank[[BR]]

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5993>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

  • [CakePHP : The Rapid Dev... CakePHP : The Rapid Development Framework for PHP

Reply via email to