Forráskód Böngészése

ZF-11019: Caching URIs with "0" as the file name

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23690 44c647ce-9c0f-0410-b52a-842ac1e357ba
mabe 15 éve
szülő
commit
1df53cfce1

+ 5 - 5
library/Zend/Cache/Backend/Static.php

@@ -123,7 +123,7 @@ class Zend_Cache_Backend_Static
      */
     public function load($id, $doNotTestCacheValidity = false)
     {
-        if (empty($id)) {
+        if (($id = (string)$id) === '') {
             $id = $this->_detectId();
         } else {
             $id = $this->_decodeId($id);
@@ -136,7 +136,7 @@ class Zend_Cache_Backend_Static
         }
 
         $fileName = basename($id);
-        if (empty($fileName)) {
+        if ($fileName === '') {
             $fileName = $this->_options['index_filename'];
         }
         $pathName = $this->_options['public_dir'] . dirname($id);
@@ -163,7 +163,7 @@ class Zend_Cache_Backend_Static
         }
 
         $fileName = basename($id);
-        if (empty($fileName)) {
+        if ($fileName === '') {
             $fileName = $this->_options['index_filename'];
         }
         if ($this->_tagged === null && $tagged = $this->getInnerCache()->load(self::INNER_CACHE_NAME)) {
@@ -211,14 +211,14 @@ class Zend_Cache_Backend_Static
         }
 
         clearstatcache();
-        if ($id === null || strlen($id) == 0) {
+        if (($id = (string)$id) === '') {
             $id = $this->_detectId();
         } else {
             $id = $this->_decodeId($id);
         }
 
         $fileName = basename($id);
-        if (empty($fileName)) {
+        if ($fileName === '') {
             $fileName = $this->_options['index_filename'];
         }
 

+ 9 - 0
tests/Zend/Cache/StaticBackendTest.php

@@ -130,6 +130,15 @@ class Zend_Cache_StaticBackendTest extends Zend_Cache_CommonBackendTest {
         rmdir($this->_instance->getOption('public_dir') . '/foo');
     }
 
+    public function testFilename0()
+    {
+        $res = $this->_instance->save('content', bin2hex('/0'));
+        $this->assertTrue($res);
+
+        $this->assertTrue($this->_instance->test(bin2hex('/0')));
+        $this->assertEquals('content', $this->_instance->load(bin2hex('/0')));
+    }
+
     public function testDirectoryUmaskAsString()
     {
         $this->_instance->setOption('cache_directory_umask', '777');