"Fixes #4232, Problem with stripslashes in cached files.

Added tmp directory to tests/tests_app
Added file to mimic windows cached file
Added test case"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6607 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2008-03-26 15:34:56 +00:00
parent 0ef028bc1f
commit 2c5ac9cfb9
3 changed files with 46 additions and 5 deletions

View file

@ -175,13 +175,11 @@ class FileEngine extends CacheEngine {
$data = $this->__File->read(true);
if ($data !== '' && !empty($this->settings['serialize'])) {
$data = stripslashes($data);
if (substr(PHP_OS, 0, 3) == "WIN") {
$data = str_replace('\\\\\\\\', '\\', $data);
}
$data = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $data);
$data = unserialize($data);
if (is_array($data)) {
$data = array_map('stripslashes_deep', $data);
}
}
$this->__File->close();
return $data;

View file

@ -220,6 +220,47 @@ class FileEngineTest extends UnitTestCase {
$this->assertTrue($result);
}
function testRemoveWindowsSlashesFromCache() {
$File = new File(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'tmp' . DS . 'dir_map');
$File->read(11);
$data = $File->read(true);
$data = str_replace('\\\\\\\\', '\\', $data);
$data = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $data);
$data = unserialize($data);
$expected = array (
'C:\dev\prj2\sites\cake\libs' => array(
0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view',
2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages',
4 => 'C:\dev\prj2\sites\cake\libs\view\layouts', 5 => 'C:\dev\prj2\sites\cake\libs\view\layouts\xml',
6 => 'C:\dev\prj2\sites\cake\libs\view\layouts\rss', 7 => 'C:\dev\prj2\sites\cake\libs\view\layouts\js',
8 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email', 9 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\text',
10 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\html', 11 => 'C:\dev\prj2\sites\cake\libs\view\helpers',
12 => 'C:\dev\prj2\sites\cake\libs\view\errors', 13 => 'C:\dev\prj2\sites\cake\libs\view\elements',
14 => 'C:\dev\prj2\sites\cake\libs\view\elements\email', 15 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\text',
16 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\html', 17 => 'C:\dev\prj2\sites\cake\libs\model',
18 => 'C:\dev\prj2\sites\cake\libs\model\datasources', 19 => 'C:\dev\prj2\sites\cake\libs\model\datasources\dbo',
20 => 'C:\dev\prj2\sites\cake\libs\model\behaviors', 21 => 'C:\dev\prj2\sites\cake\libs\controller',
22 => 'C:\dev\prj2\sites\cake\libs\controller\components', 23 => 'C:\dev\prj2\sites\cake\libs\cache'),
'C:\dev\prj2\sites\main_site\vendors' => array(
0 => 'C:\dev\prj2\sites\main_site\vendors', 1 => 'C:\dev\prj2\sites\main_site\vendors\shells',
2 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates', 3 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates\cdc_project',
4 => 'C:\dev\prj2\sites\main_site\vendors\shells\tasks', 5 => 'C:\dev\prj2\sites\main_site\vendors\js',
6 => 'C:\dev\prj2\sites\main_site\vendors\css'),
'C:\dev\prj2\sites\vendors' => array(
0 => 'C:\dev\prj2\sites\vendors', 1 => 'C:\dev\prj2\sites\vendors\simpletest',
2 => 'C:\dev\prj2\sites\vendors\simpletest\test', 3 => 'C:\dev\prj2\sites\vendors\simpletest\test\support',
4 => 'C:\dev\prj2\sites\vendors\simpletest\test\support\collector', 5 => 'C:\dev\prj2\sites\vendors\simpletest\extensions',
6 => 'C:\dev\prj2\sites\vendors\simpletest\extensions\testdox', 7 => 'C:\dev\prj2\sites\vendors\simpletest\docs',
8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'),
'C:\dev\prj2\sites\main_site\views\helpers' => array(
0 => 'C:\dev\prj2\sites\main_site\views\helpers'));
$File->close();
$this->assertEqual($expected, $data);
}
function tearDown() {
Cache::config('default');
}

View file

@ -0,0 +1,2 @@
1205865293
a:4:{s:27:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs";a:24:{i:0;s:27:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs";i:1;s:32:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view";i:2;s:42:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\scaffolds";i:3;s:38:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\pages";i:4;s:40:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts";i:5;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\xml";i:6;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\rss";i:7;s:43:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\js";i:8;s:46:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\email";i:9;s:51:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\text";i:10;s:51:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\html";i:11;s:40:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\helpers";i:12;s:39:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\errors";i:13;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements";i:14;s:47:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements\\\\email";i:15;s:52:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\text";i:16;s:52:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\html";i:17;s:33:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model";i:18;s:45:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model\\\\datasources";i:19;s:49:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model\\\\datasources\\\\dbo";i:20;s:43:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\model\\\\behaviors";i:21;s:38:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\controller";i:22;s:49:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\controller\\\\components";i:23;s:33:"C:\\\\dev\\\\prj2\\\\sites\\\\cake\\\\libs\\\\cache";}s:35:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors";a:7:{i:0;s:35:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors";i:1;s:42:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells";i:2;s:52:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells\\\\templates";i:3;s:64:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells\\\\templates\\\\cdc_project";i:4;s:48:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\shells\\\\tasks";i:5;s:38:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\js";i:6;s:39:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\vendors\\\\css";}s:25:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors";a:10:{i:0;s:25:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors";i:1;s:36:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest";i:2;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\test";i:3;s:49:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\test\\\\support";i:4;s:59:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\test\\\\support\\\\collector";i:5;s:47:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\extensions";i:6;s:55:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\extensions\\\\testdox";i:7;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\docs";i:8;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\docs\\\\fr";i:9;s:44:"C:\\\\dev\\\\prj2\\\\sites\\\\vendors\\\\simpletest\\\\docs\\\\en";}s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\views\\\\helpers";a:1:{i:0;s:41:"C:\\\\dev\\\\prj2\\\\sites\\\\main_site\\\\views\\\\helpers";}}